diff options
author | Hung-Te Lin <hungte@chromium.org> | 2018-08-31 15:52:31 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-10 01:13:18 -0700 |
commit | e0b83db84ae33e3b02c975c522e924f13d896d79 (patch) | |
tree | 23ff2455497ff8a6bcc39e1323b2ed99d9519fd9 /futility | |
parent | e5cd1b321916df9c36770f06d28ec86bca98d116 (diff) | |
download | vboot-e0b83db84ae33e3b02c975c522e924f13d896d79.tar.gz |
futility: cmd_update: Add new 'legacy' mode
For devices that do not have update tag provisioned in legacy CBFS, we
need a way to push and enforce the updater to complete first migration.
The '--mode=legacy' provides a short cut to do
"flashrom -p host -w image -i RW_LEGACY"
Devices that need newer (or latest) legacy firmware should invoke
firmware updater in their initialization or setup process, to enforce
updating RW_LEGACY.
BUG=chromium:875551
TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None
Change-Id: I87db067ad134e82bbbdc937bd2880c6731ec892b
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1198808
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility')
-rw-r--r-- | futility/cmd_update.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c index 3c12d565..9055ec4a 100644 --- a/futility/cmd_update.c +++ b/futility/cmd_update.c @@ -117,6 +117,7 @@ struct updater_config { struct firmware_image ec_image, pd_image; int try_update; int force_update; + int legacy_update; int emulate; struct system_property system_properties[SYS_PROP_MAX]; }; @@ -1175,7 +1176,6 @@ static int legacy_needs_update(struct updater_config *cfg) has_to = cbfs_file_exists(cfg->image.file_name, section, tag); has_from = cbfs_file_exists(cfg->image_current.file_name, section, tag); - /* TODO)hungte): Add a quirk so we can upgrade systems without tags. */ if (!has_from || !has_to) { DEBUG("Current legacy firmware has%s updater tag (%s) " "and target firmware has%s updater tag, won't update.", @@ -1361,6 +1361,23 @@ static enum updater_error_codes update_rw_firmrware( } /* + * The main updater for "Legacy update". + * This is equivalent to --mode=legacy. + * Returns UPDATE_ERR_DONE if success, otherwise error. + */ +static enum updater_error_codes update_legacy_firmware( + struct updater_config *cfg, + struct firmware_image *image_to) +{ + printf(">> LEGACY UPDATE: Updating firmware %s.\n", FMAP_RW_LEGACY); + + if (write_firmware(cfg, image_to, FMAP_RW_LEGACY)) + return UPDATE_ERR_WRITE_FIRMWARE; + + return UPDATE_ERR_DONE; +} + +/* * The main updater for "Full update". * This was also known as "--mode=factory" or "--mode=recovery, --wp=0" in * legacy updater. @@ -1427,6 +1444,9 @@ static enum updater_error_codes update_firmware(struct updater_config *cfg) if (debugging_enabled) print_system_properties(cfg); + if (cfg->legacy_update) + return update_legacy_firmware(cfg, image_to); + if (cfg->try_update) { enum updater_error_codes r; r = update_try_rw_firmware(cfg, image_from, image_to, @@ -1545,7 +1565,10 @@ static int do_update(int argc, char *argv[]) cfg.try_update = 1; } else if (strcmp(optarg, "recovery") == 0) { cfg.try_update = 0; - } else if (strcmp(optarg, "factory") == 0) { + } else if (strcmp(optarg, "legacy") == 0) { + cfg.legacy_update = 1; + } else if (strcmp(optarg, "factory") == 0 || + strcmp(optarg, "factory_install") == 0) { cfg.try_update = 0; if (!is_write_protection_enabled(&cfg)) { errorcnt++; |