summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorRuben Rodriguez Buchillon <coconutruben@chromium.org>2021-01-29 18:29:15 -0800
committerCommit Bot <commit-bot@chromium.org>2021-02-04 18:54:25 +0000
commit7a46d22984d7658e03d49e9ce54a3ee67d48393c (patch)
tree8ceb9db65d7c0482d6e21a5470c104301370e3fb /extra
parentaa0693de228f6fb3ccba2beb859a6c8d37e5d830 (diff)
downloadchrome-ec-7a46d22984d7658e03d49e9ce54a3ee67d48393c.tar.gz
servo_updater: cleanup and choices
This change has some minor cleanup and introduces the usage of 'choices' to the board argument, to stop errors on argument parsing already. BRANCH=None BUG=b:179310743 TEST=servo_updater --help | grep board -b {c2d2,servo_micro,servo_v4,servo_v4p1,sweetberry}, --board [...] Change-Id: I676a5250d4721a309eec4a50a585a5ed719095b6 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2661018 Reviewed-by: Brian Nemec <bnemec@chromium.org>
Diffstat (limited to 'extra')
-rwxr-xr-xextra/usb_updater/servo_updater.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py
index 64aa6bb21b..a9638c194f 100755
--- a/extra/usb_updater/servo_updater.py
+++ b/extra/usb_updater/servo_updater.py
@@ -32,6 +32,11 @@ BOARD_SWEETBERRY = 'sweetberry'
DEFAULT_BOARD = BOARD_SERVO_V4
+# These lists are to facilitate exposing choices in the command-line tool
+# below.
+BOARDS = [BOARD_C2D2, BOARD_SERVO_MICRO, BOARD_SERVO_V4, BOARD_SERVO_V4P1,
+ BOARD_SWEETBERRY]
+
DEFAULT_BASE_PATH = '/usr/'
TEST_IMAGE_BASE_PATH = '/usr/local/'
@@ -255,7 +260,8 @@ def findfiles(cname, fname):
if os.path.isfile(newname):
fname = newname
else:
- raise ServoUpdaterException("Can't find firmware binary: %s." % binary_file)
+ raise ServoUpdaterException("Can't find firmware binary: %s." %
+ binary_file)
elif not os.path.isfile(fname):
# If a name is specified but not found, try the default path.
newname = os.path.join(firmware_path, fname)
@@ -290,17 +296,18 @@ def find_available_version(boardname, binfile):
def main():
parser = argparse.ArgumentParser(description="Image a servo micro device")
parser.add_argument('-s', '--serialno', type=str,
- help="serial number to program", default=None)
+ help="serial number to program", default=None)
parser.add_argument('-b', '--board', type=str,
- help="Board configuration json file", default=DEFAULT_BOARD)
+ help="Board configuration json file",
+ default=DEFAULT_BOARD, choices=BOARDS)
parser.add_argument('-f', '--file', type=str,
- help="Complete ec.bin file", default=None)
+ help="Complete ec.bin file", default=None)
parser.add_argument('--force', action="store_true",
- help="Update even if version match", default=False)
+ help="Update even if version match", default=False)
parser.add_argument('-v', '--verbose', action="store_true",
- help="Chatty output")
+ help="Chatty output")
parser.add_argument('-r', '--reboot', action="store_true",
- help="Always reboot, even after probe.")
+ help="Always reboot, even after probe.")
args = parser.parse_args()