summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-09-22 13:07:11 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-27 19:43:58 -0700
commita61d3d89c7717d86632cdc1d92bee1ac55fcb83b (patch)
treeca5c8d2068d7d21a3b4d0175dea4f636aa877666
parentd35d0566f16122195b210c365ee8e831a2544f61 (diff)
downloadvboot-a61d3d89c7717d86632cdc1d92bee1ac55fcb83b.tar.gz
futility: update: Add --programmer to override flashrom programmer for servo
Many developers need to reflash or update firmware using servo, and the firmware logic has been complicated enough that simply calling 'flashrom -w image.bin -p $SERVO' will usually destroy many important settings, for example HWID, VPD, and other data provisioned in factory. It should be more convenient if we can use 'futility update' against servo. The '--programmer' provides first step - to override the flashrom programmer so we can read and write via special programmer (like servo). With this change, developers can reflash using: futility -p $SERVO -i $IMAGE --force --wp 0 BRANCH=None BUG=b:116326638 TEST=make futil; sudo tests/futility/run_test_scripts.sh $(pwd)/build/futility Change-Id: Iad4819ff8258086e1abb58fefd462d94050754d0 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1239817 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--futility/cmd_update.c31
-rwxr-xr-xtests/futility/test_update.sh10
2 files changed, 34 insertions, 7 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c
index 6bc68524..19d118c0 100644
--- a/futility/cmd_update.c
+++ b/futility/cmd_update.c
@@ -1777,6 +1777,7 @@ static struct option const long_opts[] = {
{"mode", 1, NULL, 'm'},
{"factory", 0, NULL, 'Y'},
{"force", 0, NULL, 'F'},
+ {"programmer", 1, NULL, 'p'},
{"wp", 1, NULL, 'W'},
{"emulate", 1, NULL, 'E'},
{"sys_props", 1, NULL, 'S'},
@@ -1786,7 +1787,7 @@ static struct option const long_opts[] = {
{NULL, 0, NULL, 0},
};
-static const char * const short_opts = "hi:e:tm:dv";
+static const char * const short_opts = "hi:e:tm:p:dv";
static void print_help(int argc, char *argv[])
{
@@ -1797,6 +1798,7 @@ static void print_help(int argc, char *argv[])
"-e, --ec_image=FILE \tEC firmware image (i.e, ec.bin)\n"
" --pd_image=FILE \tPD firmware image (i.e, pd.bin)\n"
"-t, --try \tTry A/B update on reboot if possible\n"
+ "-p, --programmer=PRG\tChange AP (host) flashrom programmer\n"
" --quirks=LIST \tSpecify the quirks to apply\n"
" --list-quirks \tPrint all available quirks\n"
"\n"
@@ -1817,8 +1819,9 @@ static void print_help(int argc, char *argv[])
static int do_update(int argc, char *argv[])
{
- int i, r, errorcnt = 0;
+ int i, r, single_image = 0, errorcnt = 0;
int check_wp_disabled = 0;
+ char *opt_programmer = NULL;
struct updater_config cfg = {
.image = { .programmer = PROG_HOST, },
.image_current = { .programmer = PROG_HOST, },
@@ -1907,6 +1910,9 @@ static int do_update(int argc, char *argv[])
cfg.emulation = strdup(optarg);
DEBUG("Emulate with file: %s", cfg.emulation);
break;
+ case 'p':
+ opt_programmer = strdup(optarg);
+ break;
case 'F':
cfg.force_update = 1;
break;
@@ -1943,14 +1949,20 @@ static int do_update(int argc, char *argv[])
errorcnt++;
Error("Unexpected arguments.\n");
}
+ if (opt_programmer) {
+ single_image = 1;
+ cfg.image.programmer = opt_programmer;
+ cfg.image_current.programmer = opt_programmer;
+ DEBUG("AP (host) programmer changed to %s.", opt_programmer);
+ }
if (cfg.emulation) {
- if (cfg.ec_image.data || cfg.pd_image.data) {
- errorcnt++;
- Error("EC/PD images are not supported in emulation.\n");
- }
- /* We only support emulating AP firmware. */
+ single_image = 1;
errorcnt += load_image(cfg.emulation, &cfg.image_current);
}
+ if (single_image && (cfg.ec_image.data || cfg.pd_image.data)) {
+ errorcnt++;
+ Error("EC/PD images are not supported in current mode.\n");
+ }
if (check_wp_disabled && is_write_protection_enabled(&cfg)) {
errorcnt++;
Error("Factory mode needs WP disabled.\n");
@@ -1967,6 +1979,11 @@ static int do_update(int argc, char *argv[])
errorcnt ? "FAILED": "DONE",
errorcnt ? "stopped due to error" : "exited successfully");
unload_updater_config(&cfg);
+ if (opt_programmer) {
+ cfg.image.programmer = PROG_HOST;
+ cfg.image_current.programmer = PROG_HOST;
+ free(opt_programmer);
+ }
remove_all_temp_files();
return !!errorcnt;
}
diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh
index c5615f0f..1b80e2e5 100755
--- a/tests/futility/test_update.sh
+++ b/tests/futility/test_update.sh
@@ -277,3 +277,13 @@ test_update "Full update (--quirks min_platform_version)" \
"${FROM_IMAGE}" "${TMP}.expected.full" \
--quirks min_platform_version=3 \
-i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1,3
+
+# Test special programmer
+if type flashrom >/dev/null 2>&1; then
+ echo "TEST: Full update (dummy programmer)"
+ cp -f "${FROM_IMAGE}" "${TMP}.emu"
+ sudo "${FUTILITY}" update --programmer \
+ dummy:emulate=VARIABLE_SIZE,image=${TMP}.emu,size=8388608 \
+ -i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1,3 >&2
+ cmp "${TMP}.emu" "${TMP}.expected.full"
+fi