summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2017-02-24 17:14:49 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-03-13 23:50:06 +0000
commite47c0e6f5f596fcf75ac212232b171e9baeccb64 (patch)
tree705e355a6032e4a54f7b67061b55ef275c8d2138
parent6f65dda5ac5ba02a5e6f732a8a688223864736c1 (diff)
downloadchrome-ec-e47c0e6f5f596fcf75ac212232b171e9baeccb64.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. Original Change-Id: I64328973a2dfac1b78262f1ffacd677e52956d27 Original Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Original Reviewed-on: https://chromium-review.googlesource.com/446939 Original Reviewed-by: Aaron Durbin <adurbin@chromium.org> Change-Id: Ic0ee4e1487c03230b5648be579f313c7ab80017f Reviewed-on: https://chromium-review.googlesource.com/958703 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Marco Chen <marcochen@chromium.org> Commit-Queue: Marco Chen <marcochen@chromium.org>
-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;