diff options
author | Brian J. Nemec <bnemec@chromium.org> | 2020-04-06 22:46:48 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-08 23:45:00 +0000 |
commit | 752edaacb1867a74e548308217f843ea7a2962eb (patch) | |
tree | 3b797609b3a77d90d11bd542ad7ddba3f7435e47 | |
parent | 3c11c513542f692e26b15277799ccc90d0c6455d (diff) | |
download | chrome-ec-752edaacb1867a74e548308217f843ea7a2962eb.tar.gz |
servo_updater: Add Servo V4.1 to flash and servo updater
Adds the Servo V4.1 to the servo updater as the target 'servo_v41'.
Some minor cleanup was done on the servo_updater logic to make it
clearer which issue is occurring and to address common substrings
in 'servo_v4' and 'servo_v41' by extracting the binary name from
the config files directly rather than inferring from the name.
BUG=b:153391164
TEST=sudo emerge chromeos-base/ec-devutils
TEST=flash_ec --board=servo_v41 --image ec.bin
Verify the flash_ec using the STM32 DFU to flash the image on
reworked board with compatible BC1.2 change
TEST=sudo servo_updater -b servo_v41
Verify the servo_updater finds the latest servo_v4.1 version and
flashes it
TEST=Attempted to flash V4 and V41 devices with each other's images
verified that the checks prevent flashing the other version.
Change-Id: I77d94ce9a641f39b7ee446af05e52441b7762c96
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2138638
Tested-by: Brian Nemec <bnemec@chromium.org>
Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Commit-Queue: Brian Nemec <bnemec@chromium.org>
-rwxr-xr-x | extra/usb_updater/servo_updater.py | 32 | ||||
-rw-r--r-- | extra/usb_updater/servo_v41.json | 15 | ||||
-rw-r--r-- | setup.py | 1 | ||||
-rwxr-xr-x | util/flash_ec | 1 |
4 files changed, 32 insertions, 17 deletions
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py index 415c38ea3d..f1bf0a8a67 100755 --- a/extra/usb_updater/servo_updater.py +++ b/extra/usb_updater/servo_updater.py @@ -21,11 +21,7 @@ import ecusb.tiny_servo_common as c class ServoUpdaterException(Exception): """Raised on exceptions generated by servo_updater.""" -BOARD_C2D2 = "c2d2" -BOARD_SERVO_MICRO = "servo_micro" -BOARD_SERVO_V4 = "servo_v4" -BOARD_SWEETBERRY = "sweetberry" -SERVO_BOARDS = (BOARD_C2D2, BOARD_SERVO_MICRO, BOARD_SERVO_V4, BOARD_SWEETBERRY) +DEFAULT_BOARD = "servo_v4" DEFAULT_BASE_PATH = '/usr/' TEST_IMAGE_BASE_PATH = '/usr/local/' @@ -172,7 +168,7 @@ def findfiles(cname, fname): check for board.json, board.bin Args: - cname: config name, or board name. eg. "servo_v4". + cname: board name, or config name. eg. "servo_v4" or "servo_v4.json" fname: firmware binary name. Can be None to try default. Returns: cname, fname: validated filenames selected from the path. @@ -196,22 +192,24 @@ def findfiles(cname, fname): newname = os.path.join(configs_path, cname) if os.path.isfile(newname): cname = newname - elif os.path.isfile(newname + ".json"): + else: # Try appending ".json" to convert board name to config file. cname = newname + ".json" - else: - raise ServoUpdaterException("Can't find file: %s." % cname) + if not os.path.isfile(cname): + raise ServoUpdaterException("Can't find config file: %s." % cname) if not fname: # If None, try to infer board name from config. - for board in SERVO_BOARDS: - if board in cname: - newname = os.path.join(firmware_path, board + ".bin") - if os.path.isfile(newname): - fname = newname - break + with open(cname) as data_file: + data = json.load(data_file) + boardname = data['board'] + + binary_file = boardname + ".bin" + newname = os.path.join(firmware_path, binary_file) + if os.path.isfile(newname): + fname = newname else: - raise ServoUpdaterException("Can't find firmware 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) @@ -247,7 +245,7 @@ def main(): parser.add_argument('-s', '--serialno', type=str, help="serial number to program", default=None) parser.add_argument('-b', '--board', type=str, - help="Board configuration json file", default=BOARD_SERVO_V4) + help="Board configuration json file", default=DEFAULT_BOARD) parser.add_argument('-f', '--file', type=str, help="Complete ec.bin file", default=None) parser.add_argument('--force', action="store_true", diff --git a/extra/usb_updater/servo_v41.json b/extra/usb_updater/servo_v41.json new file mode 100644 index 0000000000..6a5b367450 --- /dev/null +++ b/extra/usb_updater/servo_v41.json @@ -0,0 +1,15 @@ +{ + "Comment": "This file describes the updateable sections of the flash.", + "board": "servo_v41", + "vid": "0x18d1", + "pid": "0x520d", + "console": "0", + "Comment on flash": "This is the base address of writeable flash", + "flash": "0x8000000", + "Comment on region format": "name: [baseoffset, length]", + "regions": { + "RW": ["0x10000", "0x10000"], + "PSTATE": ["0xf000", "0x1000"], + "RO": ["0x0000", "0xf000"] + } +} @@ -41,6 +41,7 @@ setup( data_files=[("share/servo_updater/configs", ["extra/usb_updater/c2d2.json", "extra/usb_updater/servo_v4.json", + "extra/usb_updater/servo_v41.json", "extra/usb_updater/servo_micro.json", "extra/usb_updater/sweetberry.json"])], description="Servo usb updater.", diff --git a/util/flash_ec b/util/flash_ec index 1c5d4db4cb..6d8c7ba9fa 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -100,6 +100,7 @@ BOARDS_STM32_DFU=( twinkie discovery servo_v4 + servo_v41 servo_micro sweetberry polyberry |