diff options
author | Hung-Te Lin <hungte@chromium.org> | 2018-11-07 16:52:58 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-14 21:30:31 -0800 |
commit | 50354b924b13e780a398c5d6b57c726992049d6e (patch) | |
tree | 96cafa0b941aef4b7ddcf0955d1a3ec683dada2d | |
parent | 4c56ba267ecc722d929e7720789ea6183c54bd2a (diff) | |
download | vboot-50354b924b13e780a398c5d6b57c726992049d6e.tar.gz |
futility: updater: Check EC/PD WP state again before updating
There are devices, especially during or after RMA, may have WP states
not synced; for example
HW = 1
SW (AP) = 0
SW (EC) = 1
In this case, we can still update host firmware but not EC. This happens
more often on EC that needs an extra reboot to change WP states.
As a result, we do want to check real programmer again before updating
optional images.
BUG=chromium:902546
TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None
Change-Id: I9a526cde19a1ab3c41afecb4f7247bd941edc3f4
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1322295
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | futility/updater.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/futility/updater.c b/futility/updater.c index f5c75e45..369a55f2 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -317,10 +317,16 @@ static int host_flashrom(enum flashrom_ops op, const char *image_path, return r; } -/* Helper function to return software write protection switch status. */ +/* Helper function to return write protection status via given programmer. */ +static int host_get_wp(const char *programmer) +{ + return host_flashrom(FLASHROM_WP_STATUS, NULL, programmer, 0, NULL); +} + +/* Helper function to return host software write protection status. */ static int host_get_wp_sw() { - return host_flashrom(FLASHROM_WP_STATUS, NULL, PROG_HOST, 0, NULL); + return host_get_wp(PROG_HOST); } /* @@ -847,7 +853,8 @@ static int write_firmware(struct updater_config *cfg, */ static int write_optional_firmware(struct updater_config *cfg, const struct firmware_image *image, - const char *section_name) + const char *section_name, + int check_programmer_wp) { if (!image->data) { DEBUG("No data in <%s> image.", image->programmer); @@ -859,6 +866,18 @@ static int write_optional_firmware(struct updater_config *cfg, return 0; } + /* + * EC & PD may have different WP settings and we want to write + * only if it is OK. + */ + if (check_programmer_wp && + get_system_property(SYS_PROP_WP_HW, cfg) == WP_ENABLED && + host_get_wp(image->programmer) == WP_ENABLED) { + ERROR("Target %s has write protection enabled, skip updating.", + image->programmer); + return 0; + } + return write_firmware(cfg, image, section_name); } @@ -1481,7 +1500,7 @@ static enum updater_error_codes update_rw_firmrware( if (write_firmware(cfg, image_to, FMAP_RW_SECTION_A) || write_firmware(cfg, image_to, FMAP_RW_SECTION_B) || write_firmware(cfg, image_to, FMAP_RW_SHARED) || - write_optional_firmware(cfg, image_to, FMAP_RW_LEGACY)) + write_optional_firmware(cfg, image_to, FMAP_RW_LEGACY, 0)) return UPDATE_ERR_WRITE_FIRMWARE; return UPDATE_ERR_DONE; @@ -1526,8 +1545,8 @@ static enum updater_error_codes update_whole_firmware( /* FMAP may be different so we should just update all. */ if (write_firmware(cfg, image_to, NULL) || - write_optional_firmware(cfg, &cfg->ec_image, NULL) || - write_optional_firmware(cfg, &cfg->pd_image, NULL)) + write_optional_firmware(cfg, &cfg->ec_image, NULL, 1) || + write_optional_firmware(cfg, &cfg->pd_image, NULL, 1)) return UPDATE_ERR_WRITE_FIRMWARE; return UPDATE_ERR_DONE; |