diff options
author | Nick Sanders <nsanders@chromium.org> | 2018-05-11 14:48:36 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-11 23:22:26 -0700 |
commit | 53f61a76b74204b4e44679aa24047c97569c8d1e (patch) | |
tree | 6cacfdce769581050ba8d0ba403180a0520e63d5 /extra | |
parent | 0b6da3c5d846cd163b47536bd789b0bdc94a5040 (diff) | |
download | chrome-ec-53f61a76b74204b4e44679aa24047c97569c8d1e.tar.gz |
servo_updater: support old and new updater
Add support for usb_updater2 in servo_updater.
This allows update back and forth between servo-9040.B
releases and builds from master, although they have
different updater enpoint interfaces.
Also add '-n' no force reboot to usb_updater2 as force reboot
is incompatible with servo_updater's flow.
BRANCH=None
BUG=b:69016431
TEST=update servo v4
Change-Id: I18809590c2e7e1cfcf60c4c97e956dfc22d85856
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1056157
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'extra')
-rwxr-xr-x | extra/usb_updater/servo_updater.py | 61 | ||||
-rw-r--r-- | extra/usb_updater/usb_updater2.c | 9 |
2 files changed, 65 insertions, 5 deletions
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py index 0cee44adc6..68ee75d553 100755 --- a/extra/usb_updater/servo_updater.py +++ b/extra/usb_updater/servo_updater.py @@ -40,6 +40,22 @@ def flash(brdfile, serialno, binfile): print("Done. Finalizing.") p.stop() +def flash2(vidpid, serialno, binfile): + """Call fw update via usb_updater2 commandline.""" + cmd = "usb_updater2 -d %s" % vidpid + if serialno: + cmd += " -S %s" % serialno + cmd += " -n" + cmd += " %s" % binfile + + print(cmd) + res = subprocess.call(cmd.split()) + + if res in (0, 1, 2): + return res + else: + raise ServoUpdaterException("usb_updater2 exit with res = %d" % res) + def connect(vidpid, iface, serialno, debuglog=False): """Connect to console. @@ -69,7 +85,10 @@ def select(vidpid, iface, serialno, region, debuglog=False): pty = connect(vidpid, iface, serialno) - cmd = "sysjump %s\nreboot" % region + if region is "ro": + cmd = "reboot" + else: + cmd = "sysjump %s" % region pty._issue_cmd(cmd) time.sleep(1) pty.close() @@ -98,6 +117,28 @@ def do_version(vidpid, iface, serialno): return results[1].strip(' \t\r\n\0') +def do_updater_version(vidpid, iface, serialno): + """Check whether this uses python updater or c++ updater + + Args: + see connect() + + Returns: + updater version number. 2 or 6. + """ + vers = do_version(vidpid, iface, serialno) + + m = re.search('_v1.1.(\d\d\d\d)-', vers) + if m: + version_number = int(m.group(1)) + # Servo versions below 58 are from servo-9040.B. + # Updater version is not directly queryable. + if version_number < 5800: + return 2 + else: + return 6 + return 0 + def findfiles(cname, fname): """Select config and firmware binary files. @@ -203,11 +244,25 @@ def main(): select(vidpid, iface, serialno, "ro", debuglog=debuglog) - flash(brdfile, serialno, binfile) + vers = do_updater_version(vidpid, iface, serialno) + if vers == 2: + flash(brdfile, serialno, binfile) + elif vers == 6: + flash2(vidpid, serialno, binfile) + else: + raise ServoUpdaterException("Can't detect updater version") select(vidpid, iface, serialno, "rw", debuglog=debuglog) - flash(brdfile, serialno, binfile) + vers = do_updater_version(vidpid, iface, serialno) + if vers == 2: + flash(brdfile, serialno, binfile) + elif vers == 6: + flash2(vidpid, serialno, binfile) + else: + raise ServoUpdaterException("Can't detect updater version") + + select(vidpid, iface, serialno, "ro", debuglog=debuglog) if __name__ == "__main__": main() diff --git a/extra/usb_updater/usb_updater2.c b/extra/usb_updater/usb_updater2.c index 957881feb0..0c5f30581c 100644 --- a/extra/usb_updater/usb_updater2.c +++ b/extra/usb_updater/usb_updater2.c @@ -72,7 +72,7 @@ static struct first_response_pdu targ; static uint16_t protocol_version; static uint16_t header_type; static char *progname; -static char *short_opts = "bd:efg:hjp:rsS:tuw"; +static char *short_opts = "bd:efg:hjnp:rsS:tuw"; static const struct option long_opts[] = { /* name hasarg *flag val */ {"binvers", 1, NULL, 'b'}, @@ -82,6 +82,7 @@ static const struct option long_opts[] = { {"tp_debug", 1, NULL, 'g'}, {"help", 0, NULL, 'h'}, {"jump_to_rw", 0, NULL, 'j'}, + {"no_reset", 0, NULL, 'n'}, {"tp_update", 1, NULL, 'p'}, {"reboot", 0, NULL, 'r'}, {"stay_in_ro", 0, NULL, 's'}, @@ -973,6 +974,7 @@ int main(int argc, char *argv[]) int transferred_sections = 0; int binary_vers = 0; int show_fw_ver = 0; + int no_reset_request = 0; int touchpad_update = 0; int extra_command = -1; uint8_t extra_command_data[50]; @@ -1025,6 +1027,9 @@ int main(int argc, char *argv[]) case 'j': extra_command = UPDATE_EXTRA_CMD_JUMP_TO_RW; break; + case 'n': + no_reset_request = 1; + break; case 'p': touchpad_update = 1; @@ -1119,7 +1124,7 @@ int main(int argc, char *argv[]) data, data_len); free(data); - if (transferred_sections) + if (transferred_sections && !no_reset_request) generate_reset_request(&td); } } else if (extra_command > -1) { |