summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-31 15:52:31 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-10 01:13:18 -0700
commite0b83db84ae33e3b02c975c522e924f13d896d79 (patch)
tree23ff2455497ff8a6bcc39e1323b2ed99d9519fd9
parente5cd1b321916df9c36770f06d28ec86bca98d116 (diff)
downloadvboot-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>
-rw-r--r--futility/cmd_update.c27
-rwxr-xr-xtests/futility/test_update.sh8
2 files changed, 33 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++;
diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh
index d51219ff..0f3fafc7 100755
--- a/tests/futility/test_update.sh
+++ b/tests/futility/test_update.sh
@@ -79,6 +79,7 @@ cp -f "${TO_IMAGE}" "${TMP}.expected.full"
cp -f "${FROM_IMAGE}" "${TMP}.expected.rw"
cp -f "${FROM_IMAGE}" "${TMP}.expected.a"
cp -f "${FROM_IMAGE}" "${TMP}.expected.b"
+cp -f "${FROM_IMAGE}" "${TMP}.expected.legacy"
"${FUTILITY}" gbb -s --hwid="${FROM_HWID}" "${TMP}.expected.full"
"${FUTILITY}" load_fmap "${TMP}.expected.full" \
RW_VPD:${TMP}.from/RW_VPD \
@@ -92,6 +93,8 @@ cp -f "${FROM_IMAGE}" "${TMP}.expected.b"
RW_SECTION_A:${TMP}.to/RW_SECTION_A
"${FUTILITY}" load_fmap "${TMP}.expected.b" \
RW_SECTION_B:${TMP}.to/RW_SECTION_B
+"${FUTILITY}" load_fmap "${TMP}.expected.legacy" \
+ RW_LEGACY:${TMP}.to/RW_LEGACY
test_update() {
local test_name="$1"
@@ -194,3 +197,8 @@ test_update "RW update (vboot1, A->B)" \
test_update "RW update (vboot1, B->B)" \
"${FROM_IMAGE}" "${TMP}.expected.b" \
-i "${TO_IMAGE}" -t --wp=1 --sys_props 1,0 --sys_props 0,0x10001,0
+
+# Test legacy update
+test_update "Legacy update" \
+ "${FROM_IMAGE}" "${TMP}.expected.legacy" \
+ -i "${TO_IMAGE}" --mode=legacy