futility: updater: add new quirk 'external_flashrom'

The new quirk will allow the updater to easily switch the underlying
flash driver between the libflashrom and the external flashrom.

BUG=None
TEST=build and run test
BRANCH=None

Change-Id: I5b9da373b1e22a948e04d844973a5683adffe63c
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3534489
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
diff --git a/futility/updater.h b/futility/updater.h
index 30a96a3..77f4726 100644
--- a/futility/updater.h
+++ b/futility/updater.h
@@ -49,6 +49,7 @@
 	QUIRK_NO_CHECK_PLATFORM,
 	QUIRK_NO_VERIFY,
 	QUIRK_EXTRA_RETRIES,
+	QUIRK_EXTERNAL_FLASHROM,
 	QUIRK_MAX,
 };
 
diff --git a/futility/updater_quirks.c b/futility/updater_quirks.c
index 8d6114b..73b7c2f 100644
--- a/futility/updater_quirks.c
+++ b/futility/updater_quirks.c
@@ -521,6 +521,11 @@
 	quirks->name = "extra_retries";
 	quirks->help = "Extra retries when writing to system firmware.";
 	quirks->apply = NULL;  /* Simple config. */
+
+	quirks = &cfg->quirks[QUIRK_EXTERNAL_FLASHROM];
+	quirks->name = "external_flashrom";
+	quirks->help = "Use external flashrom to access the system firmware.";
+	quirks->apply = NULL;  /* Simple config. */
 }
 
 /*
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index a581c8f..762be7c 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -715,8 +715,7 @@
 static int read_flash(struct flashrom_params *params,
 		      struct updater_config *cfg)
 {
-	/* TODO(hungte): Add a quirk to allow switching to external flashrom. */
-	if (0)
+	if (get_config_quirk(QUIRK_EXTERNAL_FLASHROM, cfg))
 		return external_flashrom(FLASH_READ, params, &cfg->tempfiles);
 
 	return flashrom_read_image(params->image, NULL, params->verbose);
@@ -727,8 +726,7 @@
 {
 	int r;
 
-	/* TODO(hungte): Add a quirk to allow switching to external flashrom. */
-	if (0)
+	if (get_config_quirk(QUIRK_EXTERNAL_FLASHROM, cfg))
 		return external_flashrom(FLASH_WRITE, params, &cfg->tempfiles);
 
 	r = flashrom_write_image(params->image,