From 282ce47b9dfe6b8f18e70ac871e531e25300d313 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Buchillon Date: Wed, 3 Feb 2021 17:19:44 -0800 Subject: servo_updater: print available version This change introduces -p/--print to servo_updater. Rather than performing an update, it will print for the chosen board/channel what firmware is available. See TEST below for output. BRANCH=None BUG=b:179310743 TEST=servo_updater -b servo_micro -c alpha -p board: servo_micro channel: alpha firmware: servo_micro_v2.4.35-f1113c92b // showing py2 compatibility TEST=python2 /usr/lib64/python2.7/site-packages/servo_updater.py -b \ servo_micro --print -c alpha board: servo_micro channel: alpha firmware: servo_micro_v2.4.0-dc38d9bbb Change-Id: I9899e1cacc0496a46a41e94cc9355438a5abe491 Signed-off-by: Ruben Rodriguez Buchillon Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2674381 Reviewed-by: Brian Nemec --- extra/usb_updater/servo_updater.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'extra') diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py index 575f4dbbdb..20ef51803c 100755 --- a/extra/usb_updater/servo_updater.py +++ b/extra/usb_updater/servo_updater.py @@ -340,7 +340,10 @@ def get_files_and_version(cname, fname=None, channel=DEFAULT_CHANNEL): return cname, fname, binvers def main(): - parser = argparse.ArgumentParser(description="Image a servo micro device") + parser = argparse.ArgumentParser(description="Image a servo device") + parser.add_argument('-p', '--print', dest='print_only', action='store_true', + default=False, + help='only print available firmware for board/channel') parser.add_argument('-s', '--serialno', type=str, help="serial number to program", default=None) parser.add_argument('-b', '--board', type=str, @@ -363,6 +366,15 @@ def main(): brdfile, binfile, newvers = get_files_and_version(args.board, args.file, args.channel) + # If the user only cares about the information then just print it here, + # and exit. + if args.print_only: + output = ('board: %s\n' + 'channel: %s\n' + 'firmware: %s') % (args.board, args.channel, newvers) + print(output) + return + serialno = args.serialno with open(brdfile) as data_file: -- cgit v1.2.1