diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2017-08-15 16:34:52 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-12 01:11:59 -0700 |
commit | 4dcee1c545c31d288b23221d8e07bc452214ce7b (patch) | |
tree | 1ddab11d51dcd5c0571f6f777b655ba333cd84e6 /common/flash.c | |
parent | a52cfbc80c060d9883aee9de4e764e0b250d184a (diff) | |
download | chrome-ec-4dcee1c545c31d288b23221d8e07bc452214ce7b.tar.gz |
EFS: Add support for early firmware selection
Chromebox ECs performs EFS: verifying firmware before the AP boots.
This patch updates host commands which are required for the EFS.
The change includes:
* Update EC_CMD_FLASH_REGION_INFO to accept EC_FLASH_REGION_UPDATE
* Update EC_CMD_VBOOT_HASH to accept EC_VBOOT_HASH_OFFSET_UPDATE
When EC_FLASHS_REGION_UPDATE is specified, EC_CMD_FLASH_REGION_INFO
returns the slot which currently is not hosting a running RW copy.
When EC_VBOOT_HASH_OFFSET_UPDATE is specified, EC_CMD_VBOOT_HASH
computs the hash of the update slot. This hash covers the entire
region, including the signature at the end.
This patch undefines CONFIG_CMD_USBMUX and CONFIG_CMD_TYPEC
for gru to create space.
BUG=b:65028930
BRANCH=none
CQ-DEPEND=CL:648071
TEST=On Fizz, verify:
1. RW_B is old and updated by soft sync. RW_B is activated and
executed after reboot. System continues to boot to OS.
2. RW_A is old and updated by soft sync. RW_A is activated and
executed after reboot. System continues to boot to OS.
Change-Id: I9ece907b764d07ce94054ba27996e048c665a80a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/648448
Diffstat (limited to 'common/flash.c')
-rw-r--r-- | common/flash.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/common/flash.c b/common/flash.c index 36c4701264..3d6f579834 100644 --- a/common/flash.c +++ b/common/flash.c @@ -1286,6 +1286,28 @@ static int flash_command_protect(struct host_cmd_handler_args *args) return EC_RES_SUCCESS; } +enum flash_rw_slot flash_get_active_slot(void) +{ + uint8_t slot; + if (system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, &slot)) + slot = FLASH_RW_SLOT_A; + return slot; +} + +enum flash_rw_slot flash_get_update_slot(void) +{ +#ifdef CONFIG_VBOOT_EFS + return 1 - flash_get_active_slot(); +#else + return FLASH_RW_SLOT_A; +#endif +} + +enum system_image_copy_t flash_slot_to_image(enum flash_rw_slot slot) +{ + return slot == FLASH_RW_SLOT_A ? SYSTEM_IMAGE_RW_A : SYSTEM_IMAGE_RW_B; +} + /* * TODO(crbug.com/239197) : Adding both versions to the version mask is a * temporary workaround for a problem in the cros_ec driver. Drop @@ -1307,10 +1329,9 @@ static int flash_command_region_info(struct host_cmd_handler_args *args) EC_FLASH_REGION_START; r->size = CONFIG_RO_SIZE; break; - case EC_FLASH_REGION_RW: - r->offset = CONFIG_EC_WRITABLE_STORAGE_OFF + - CONFIG_RW_STORAGE_OFF - - EC_FLASH_REGION_START; + case EC_FLASH_REGION_ACTIVE: + r->offset = flash_get_rw_offset(flash_get_active_slot()) - + EC_FLASH_REGION_START; r->size = CONFIG_RW_SIZE; break; case EC_FLASH_REGION_WP_RO: @@ -1318,6 +1339,11 @@ static int flash_command_region_info(struct host_cmd_handler_args *args) EC_FLASH_REGION_START; r->size = CONFIG_WP_STORAGE_SIZE; break; + case EC_FLASH_REGION_UPDATE: + r->offset = flash_get_rw_offset(flash_get_update_slot()) - + EC_FLASH_REGION_START; + r->size = CONFIG_RW_SIZE; + break; default: return EC_RES_INVALID_PARAM; } |