diff options
author | Vadim Bendebury <vbendeb@google.com> | 2017-02-24 17:14:49 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-02-26 17:14:28 -0800 |
commit | 31cfc63b80ea8f5b778e6c3f568f325a6064244a (patch) | |
tree | 6d31bb188600130406f563bfbd98c6df2416daab | |
parent | 6ba124a81bd6d5af1edae5f30add22e81b8b7de7 (diff) | |
download | chrome-ec-31cfc63b80ea8f5b778e6c3f568f325a6064244a.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>
-rw-r--r-- | extra/usb_updater/usb_updater.c | 33 |
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; |