futility: updater: print flashrom execution logs on read failure

To prevent flooding AU logs, we don't want flashrom to print verbose
logs especially when reading system SPI flash. However, if anything goes
wrong it will be very helpful to have all the messages logged.

With this patch, we will try reading system flash again with max verbosity.

BUG=chromium:943262,b:169026171
TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None

Change-Id: I5469182f2628855e65546bef3abf8791261aabca
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1545598
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index 5a2a5e6..a441e03 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -639,6 +639,17 @@
 
 	r = host_flashrom(FLASHROM_READ, tmp_path, image->programmer,
 			  verbosity, NULL, NULL);
+	/*
+	 * The verbosity for host_flashrom will be translated to
+	 * (verbosity-1)*'-V', and usually 3*'-V' is enough for debugging.
+	 */
+	const int debug_verbosity = 4;
+	if (r && verbosity < debug_verbosity) {
+		/* Read again, with verbose messages for debugging. */
+		WARN("Failed reading system firmware (%d), try again...\n", r);
+		r = host_flashrom(FLASHROM_READ, tmp_path, image->programmer,
+				  debug_verbosity, NULL, NULL);
+	}
 	if (!r)
 		r = load_firmware_image(image, tmp_path, NULL);
 	return r;