summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-06-01 22:01:39 -0700
committerVadim Bendebury <vbendeb@chromium.org>2017-06-28 02:37:00 +0000
commitbbc7ab3e018a476493c8acaebce9b92172669e8c (patch)
treea8dd27b5fee4ed8a7db7ee4db5ae35af579d1f37
parent76320b5348786ded3b3c1313ad0e1b2071e3af9c (diff)
downloadchrome-ec-bbc7ab3e018a476493c8acaebce9b92172669e8c.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/551362
-rw-r--r--extra/usb_updater/usb_updater.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c
index ef0756794a..340fc791be 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/usb_updater.c
@@ -1035,13 +1035,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
@@ -1358,26 +1351,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) {