diff options
author | Mary Ruthven <mruthven@chromium.org> | 2017-04-05 12:11:06 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-04-07 14:15:36 -0700 |
commit | bcc4e087a13727755482b13b44f1ab7bfd361beb (patch) | |
tree | 2f3c1b9f5338340640a6b7dc7f4df9a8ff3f7c57 /extra/usb_updater | |
parent | ea57c36c18d6b811a58b5055969d0017f39b5162 (diff) | |
download | chrome-ec-bcc4e087a13727755482b13b44f1ab7bfd361beb.tar.gz |
usb_updater: post a reset during upstart on old versions
If Cr50 does not have support for invalidating the RW header and
restoring it, then upstart should still post a reset. This changes
usb_updater to post a restart during upstart if the RW minor version is
less than 19.
BUG=none
BRANCH=cr50
TEST=manual
Copy new usb_updater onto the DUT. run 'sync'
Build two cr50 debug images one with 0.0.19 and one with 0.1.12
verify update process works
test_that $DUT_IP -b $BOARD firmware_Cr50Update
--args="old_release_image=$PATH_TO_PROD_13
release_image=$PATH_TO_PROD_18 dev_image=$DBG_IMAGE_19"
Build a firmware image with
https://review.coreboot.org/#/c/18946/3
test_that $DUT_IP -b $BOARD firmware_Cr50Update
--args="old_release_image=$PATH_TO_PROD_18
release_image=$DBG_IMAGE_19 dev_image=$DBG_IMAGE_1_12"
Change-Id: I811977de26999b1d26bd2d4126b88b1c55a93931
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/470326
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'extra/usb_updater')
-rw-r--r-- | extra/usb_updater/usb_updater.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c index b94c6d7d64..ba1734e251 100644 --- a/extra/usb_updater/usb_updater.c +++ b/extra/usb_updater/usb_updater.c @@ -1042,6 +1042,12 @@ static int transfer_image(struct transfer_descriptor *td, return num_txed_sections; } +static struct signed_header_version ver19 = { + .epoch = 0, + .major = 0, + .minor = 19, +}; + static void generate_reset_request(struct transfer_descriptor *td) { size_t response_size; @@ -1049,6 +1055,7 @@ static void generate_reset_request(struct transfer_descriptor *td) uint16_t subcommand; uint8_t command_body[2]; /* Max command body size. */ size_t command_body_size; + uint32_t background_update_supported; if (protocol_version < 6) { if (td->ep_type == usb_xfer) { @@ -1062,8 +1069,20 @@ static void generate_reset_request(struct transfer_descriptor *td) return; } + /* RW version 0.0.19 and above has support for background updates. */ + background_update_supported = !a_newer_than_b(&ver19, &targ.shv[1]); + + /* + * If this is an upstart request and there is support for background + * updates, don't post a request now. The target should handle it on + * the next reboot. + */ + if (td->upstart_mode && background_update_supported) + return; + /* - * If the user explicitly wants it, request post reset instead of + * If the user explicitly wants it or a reset is needed because h1 + * does not support background updates, request post reset instead of * immediate reset. In this case next time the target reboots, the h1 * will reboot as well, and will consider running the uploaded code. * @@ -1076,9 +1095,9 @@ static void generate_reset_request(struct transfer_descriptor *td) /* Most common case. */ command_body_size = 0; response_size = 1; - if (td->post_reset) { + if (td->post_reset || td->upstart_mode) { subcommand = EXTENSION_POST_RESET; - } else if (targ.shv[1].minor >= 19) { + } else if (background_update_supported) { subcommand = VENDOR_CC_TURN_UPDATE_ON; command_body_size = sizeof(command_body); command_body[0] = 0; @@ -1262,7 +1281,7 @@ int main(int argc, char *argv[]) transferred_sections = transfer_image(&td, data, data_len); free(data); - if (transferred_sections && !td.upstart_mode) + if (transferred_sections) generate_reset_request(&td); } else if (corrupt_inactive_rw) { invalidate_inactive_rw(&td); |