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>
This commit is contained in:
Mary Ruthven
2017-04-05 12:11:06 -07:00
committed by chrome-bot
parent ea57c36c18
commit bcc4e087a1

View File

@@ -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 the user explicitly wants it, request post reset instead of
* 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 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);