diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2017-06-01 22:01:39 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2017-06-23 21:30:16 +0000 |
commit | 9f05ef7a2c037a4e609112761ec48691c9e9a569 (patch) | |
tree | af81a6c67468dfc72b8393b4e41bf59503383772 | |
parent | 0a3a022675e09b80b06d60359e407151a2cae062 (diff) | |
download | chrome-ec-9f05ef7a2c037a4e609112761ec48691c9e9a569.tar.gz |
cr50: usb_updater: do not send setup request unless necessary
There are only two usb_updater actions which require establishing a
connection with the Cr50: transferring the firmware image during
update and reporting the version of the running image (because the
version is reported when the connection is established).
This patch refactors usb_updater code to establish the connection only
when necessary.
BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=verified that 'usb_updater -c' succeeds both issued over USB and
TPM
Change-Id: I6a0c82eb440c092263d4802f124f458f148a8ab5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525095
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 885c02a92d35607bf410e27f27c0b35e67827cf5)
Reviewed-on: https://chromium-review.googlesource.com/547041
-rw-r--r-- | extra/usb_updater/usb_updater.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c index c39673535a..83272b2509 100644 --- a/extra/usb_updater/usb_updater.c +++ b/extra/usb_updater/usb_updater.c @@ -1044,13 +1044,6 @@ static int transfer_image(struct transfer_descriptor *td, num_txed_sections++; } - /* - * Move USB receiver sate machine to idle state so that vendor - * commands can be processed later, if any. - */ - if (td->ep_type == usb_xfer) - send_done(&td->uep); - if (!num_txed_sections) printf("nothing to do\n"); else @@ -1280,26 +1273,38 @@ int main(int argc, char *argv[]) } } - setup_connection(&td); + if (corrupt_inactive_rw) + invalidate_inactive_rw(&td); + + if (data || show_fw_ver) { + + setup_connection(&td); + + if (data) { + transferred_sections = transfer_image(&td, + data, data_len); + free(data); + } - if (show_fw_ver) { - printf("Current versions:\n"); - printf("RO %d.%d.%d\n", targ.shv[0].epoch, targ.shv[0].major, - targ.shv[0].minor); - printf("RW %d.%d.%d\n", targ.shv[1].epoch, targ.shv[1].major, - targ.shv[1].minor); + /* + * Move USB updater sate machine to idle state so that vendor + * commands can be processed later, if any. + */ if (td.ep_type == usb_xfer) send_done(&td.uep); - } - - if (data) { - transferred_sections = transfer_image(&td, data, data_len); - free(data); if (transferred_sections) generate_reset_request(&td); - } else if (corrupt_inactive_rw) { - invalidate_inactive_rw(&td); + + if (show_fw_ver) { + printf("Current versions:\n"); + printf("RO %d.%d.%d\n", targ.shv[0].epoch, + targ.shv[0].major, + targ.shv[0].minor); + printf("RW %d.%d.%d\n", targ.shv[1].epoch, + targ.shv[1].major, + targ.shv[1].minor); + } } if (td.ep_type == usb_xfer) { |