diff options
author | Ruben Rodriguez Buchillon <coconutruben@chromium.org> | 2021-01-29 18:29:33 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-12 19:35:50 +0000 |
commit | 834b3526140a60cd8db45d770c6bfaf026ff97a3 (patch) | |
tree | 3f4777917cbf5165e29583c1571fc41f5af613bf /extra | |
parent | c8ebbe6b954f9d8e00d78a07e32ff95ffc4516a6 (diff) | |
download | chrome-ec-834b3526140a60cd8db45d770c6bfaf026ff97a3.tar.gz |
servo_updater: introduce channels
This change introduces the ability to pull an update from a specific
channel (i.e. a specific file). See the bug for details on this project,
but basically the `servo-firmware` package now bundles multiple firmware
in the system, all of which are tagged to belong to a 'channel'. The
name of those files is then [board_name].[channel].bin. The updater then
now supports the notion of requesting a specific channel to update, if
the default (stable) is not desired.
Like the previous CL it also leverages choices for argparse to ensure no
unknown channels are requested.
BRANCH=None
BUG=b:179310743
TEST=servo_updater --help | grep channel
-c {alpha,dev,prev,stable}, --channel {alpha,dev,prev,stable}
TEST=sudo servo_updater --board servo_micro -c alpha
Current servo_micro version is servo_micro_v2.4.35-f1113c92b
Available servo_micro version is servo_micro_v2.4.35-f1113c92b
No version update needed
Cq-Depend: chromium:2674405
Change-Id: I88c301cc4ff0ac246cbfda6498c27a1fd23f722f
Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2661019
Reviewed-by: Brian Nemec <bnemec@chromium.org>
Diffstat (limited to 'extra')
-rwxr-xr-x | extra/usb_updater/servo_updater.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py index a9638c194f..a528caf9e6 100755 --- a/extra/usb_updater/servo_updater.py +++ b/extra/usb_updater/servo_updater.py @@ -37,6 +37,22 @@ DEFAULT_BOARD = BOARD_SERVO_V4 BOARDS = [BOARD_C2D2, BOARD_SERVO_MICRO, BOARD_SERVO_V4, BOARD_SERVO_V4P1, BOARD_SWEETBERRY] +# Servo firmware bundles four channels of firmware. We need to make sure the +# user does not request a non-existing channel, so keep the lists around to +# guard on command-line usage. + +DEFAULT_CHANNEL = STABLE_CHANNEL = 'stable' + +PREV_CHANNEL = 'prev' + +# The ordering here matters. From left to right it's the channel that the user +# is most likely to be running. This is used to inform and warn the user if +# there are issues. e.g. if the all channels are the same, we want to let the +# user know they are running the 'stable' version before letting them know they +# are running 'dev' or even 'alpah' which (while true) might cause confusion. + +CHANNELS = [DEFAULT_CHANNEL, PREV_CHANNEL, 'dev', 'alpha'] + DEFAULT_BASE_PATH = '/usr/' TEST_IMAGE_BASE_PATH = '/usr/local/' @@ -211,7 +227,7 @@ def do_updater_version(tinys): raise ServoUpdaterException( "Can't determine updater target from vers: [%s]" % vers) -def findfiles(cname, fname): +def findfiles(cname, fname, channel=DEFAULT_CHANNEL): """Select config and firmware binary files. This checks default file names and paths. @@ -221,6 +237,7 @@ def findfiles(cname, fname): Args: cname: board name, or config name. eg. "servo_v4" or "servo_v4.json" fname: firmware binary name. Can be None to try default. + channel: the channel requested for servo firmware. See |CHANNELS| above. Returns: cname, fname: validated filenames selected from the path. """ @@ -255,7 +272,7 @@ def findfiles(cname, fname): data = json.load(data_file) boardname = data['board'] - binary_file = boardname + ".bin" + binary_file = '%s.%s.bin' % (boardname, channel) newname = os.path.join(firmware_path, binary_file) if os.path.isfile(newname): fname = newname @@ -300,6 +317,9 @@ def main(): parser.add_argument('-b', '--board', type=str, help="Board configuration json file", default=DEFAULT_BOARD, choices=BOARDS) + parser.add_argument('-c', '--channel', type=str, + help="Firmware channel to use", + default=DEFAULT_CHANNEL, choices=CHANNELS) parser.add_argument('-f', '--file', type=str, help="Complete ec.bin file", default=None) parser.add_argument('--force', action="store_true", @@ -311,7 +331,7 @@ def main(): args = parser.parse_args() - brdfile, binfile = findfiles(args.board, args.file) + brdfile, binfile = findfiles(args.board, args.file, args.channel) serialno = args.serialno |