diff options
author | Hung-Te Lin <hungte@chromium.org> | 2018-09-19 14:27:30 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-09-19 08:59:51 -0700 |
commit | 580beb881061700e5f75fc21b544483b2e258952 (patch) | |
tree | 7cf621c51dbf204a125cc1eb9c96698421daf532 | |
parent | 0828bde7b1f0e932c2db0884cb6894c422672666 (diff) | |
download | vboot-580beb881061700e5f75fc21b544483b2e258952.tar.gz |
futility: update: Add legacy option '--factory'
The '--factory' is an alias to '--mode=factory_install' and was widely used
in several documents. Also moved WP check to end of argument parsing so
'--mode=factory --wp=0' can set WP correctly.
BRANCH=None
BUG=b:115764295
TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
Change-Id: I7987d77c577414efb03941442e3125f35ac5ad98
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1233373
Reviewed-by: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | futility/cmd_update.c | 17 | ||||
-rwxr-xr-x | tests/futility/test_update.sh | 12 |
2 files changed, 22 insertions, 7 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c index 47a734aa..81fd8f41 100644 --- a/futility/cmd_update.c +++ b/futility/cmd_update.c @@ -1785,6 +1785,7 @@ static struct option const long_opts[] = { {"quirks", 1, NULL, 'f'}, {"list-quirks", 0, NULL, 'L'}, {"mode", 1, NULL, 'm'}, + {"factory", 0, NULL, 'Y'}, {"force", 0, NULL, 'F'}, {"wp", 1, NULL, 'W'}, {"emulate", 1, NULL, 'E'}, @@ -1811,6 +1812,7 @@ static void print_help(int argc, char *argv[]) "\n" "Legacy and compatibility options:\n" "-m, --mode=MODE \tRun updater in given mode\n" + " --factory \tAlias for --mode=factory\n" " --force \tForce update (skip checking contents)\n" "\n" "Debugging and testing options:\n" @@ -1826,6 +1828,7 @@ static void print_help(int argc, char *argv[]) static int do_update(int argc, char *argv[]) { int i, r, errorcnt = 0; + int check_wp_disabled = 0; struct updater_config cfg = { .image = { .programmer = PROG_HOST, }, .image_current = { .programmer = PROG_HOST, }, @@ -1894,16 +1897,16 @@ static int do_update(int argc, char *argv[]) } else if (strcmp(optarg, "factory") == 0 || strcmp(optarg, "factory_install") == 0) { cfg.try_update = 0; - if (is_write_protection_enabled(&cfg)) { - errorcnt++; - Error("Mode %s needs WP disabled.\n", - optarg); - } + check_wp_disabled = 1; } else { errorcnt++; Error("Invalid mode: %s\n", optarg); } break; + case 'Y': + cfg.try_update = 0; + check_wp_disabled = 1; + break; case 'W': r = strtol(optarg, NULL, 0); override_system_property(SYS_PROP_WP_HW, &cfg, r); @@ -1955,6 +1958,10 @@ static int do_update(int argc, char *argv[]) errorcnt++; Error("Unexpected arguments.\n"); } + if (check_wp_disabled && is_write_protection_enabled(&cfg)) { + errorcnt++; + Error("Factory mode needs WP disabled.\n"); + } if (!errorcnt) { int r = update_firmware(&cfg); if (r != UPDATE_ERR_DONE) { diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh index 119974f1..b74c7ea9 100755 --- a/tests/futility/test_update.sh +++ b/tests/futility/test_update.sh @@ -223,11 +223,19 @@ test_update "RW update (vboot1, B->B)" \ # Test 'factory mode' test_update "Factory mode update (WP=0)" \ "${FROM_IMAGE}" "${TMP}.expected.full" \ - -i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1 + -i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1 --mode=factory + +test_update "Factory mode update (WP=0)" \ + "${FROM_IMAGE}" "${TMP}.expected.full" \ + --factory -i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1 test_update "Factory mode update (WP=1)" \ "${FROM_IMAGE}" "!needs WP disabled" \ - -i "${TO_IMAGE}" --wp=1 --sys_props 0,0x10001,1 + -i "${TO_IMAGE}" --wp=1 --sys_props 0,0x10001,1 --mode=factory + +test_update "Factory mode update (WP=1)" \ + "${FROM_IMAGE}" "!needs WP disabled" \ + --factory -i "${TO_IMAGE}" --wp=1 --sys_props 0,0x10001,1 # Test legacy update test_update "Legacy update" \ |