summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2017-02-24 17:14:49 -0800
committerYoucheng Syu <youcheng@google.com>2017-03-07 06:01:03 +0000
commite4d56f5870f8171a03d9c70365503e9719e15b19 (patch)
tree4627034b55c9a635e0d418add23c8b414a355fa5
parent4cef29e5f6afa0a8171d1349436cd8b62dc243d1 (diff)
downloadchrome-ec-e4d56f5870f8171a03d9c70365503e9719e15b19.tar.gz
g: usb_updater: fix option description and add post_reset
The new option allows the operator to explicitly request the post reset reboot instead of immediate reboot (which is now ignored by production cr50 images). Also sort option descriptions and move the colons where they belong (after command line arguments requiring additional parameters), BRANCH=none BUG=none TEST=running usb_updater with -b or -d without extra parameter causes the return error code and the help message printed. running $ ./extra/usb_updater/usb_updater -p build/cr50/ec.bin results in a proper image transfer, with the following reboot of the chromeos device triggering cr50 reset and the new downloaded image running. Change-Id: I64328973a2dfac1b78262f1ffacd677e52956d27 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/446939 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 31cfc63b80ea8f5b778e6c3f568f325a6064244a) Reviewed-on: https://chromium-review.googlesource.com/451040 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
-rw-r--r--extra/usb_updater/usb_updater.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c
index 50d7cfaf3c..4b33a219c1 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/usb_updater.c
@@ -204,7 +204,7 @@ struct transfer_descriptor {
*/
uint32_t ro_offset;
uint32_t rw_offset;
-
+ uint32_t post_reset;
enum transfer_type {
usb_xfer = 0,
spi_xfer = 1
@@ -217,17 +217,18 @@ struct transfer_descriptor {
static uint32_t protocol_version;
static char *progname;
-static char *short_opts = ":bcfd:hsu";
+static char *short_opts = "b:cd:fhpsu";
static const struct option long_opts[] = {
/* name hasarg *flag val */
- {"binvers", 0, NULL, 'b'},
- {"corrupt", 0, NULL, 'c'},
- {"device", 1, NULL, 'd'},
- {"help", 0, NULL, 'h'},
- {"spi", 0, NULL, 's'},
- {"upstart", 0, NULL, 'u'},
- {"fwver", 0, NULL, 'f'},
- {NULL, 0, NULL, 0},
+ {"binvers", 1, NULL, 'b'},
+ {"corrupt", 0, NULL, 'c'},
+ {"device", 1, NULL, 'd'},
+ {"fwver", 0, NULL, 'f'},
+ {"help", 0, NULL, 'h'},
+ {"post_reset", 0, NULL, 'p'},
+ {"spi", 0, NULL, 's'},
+ {"upstart", 0, NULL, 'u'},
+ {},
};
/* Prepare and transfer a block to /dev/tpm0, get a reply. */
@@ -1099,10 +1100,13 @@ static int transfer_and_reboot(struct transfer_descriptor *td,
printf("-------\nupdate complete\n");
/*
- * In upstart mode or in case target is running older protocol version
- * - post reset is requested.
+ * In upstart mode, or in case target is running older protocol
+ * version, or in case the user explicitly wants it, request post
+ * reset instead of immediate reset. In this case the h1 will reset
+ * next time the target reboots, and will consider running the
+ * uploaded code.
*/
- if (td->upstart_mode || (protocol_version <= 5))
+ if (td->upstart_mode || (protocol_version <= 5) || td->post_reset)
subcommand = EXTENSION_POST_RESET;
if (td->ep_type == usb_xfer) {
@@ -1234,6 +1238,9 @@ int main(int argc, char *argv[])
case 's':
td.ep_type = spi_xfer;
break;
+ case 'p':
+ td.post_reset = 1;
+ break;
case 'u':
td.upstart_mode = 1;
break;