futility: updater: improve updater console output

To help debugging:

- Print equivalent flashrom commands when reading and writing.
- Print <sys-flash> instead of <none> in 'Current system:' message.
- Always print the detected model from libcrosid.
- After writing to flash, print a new line.

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

Change-Id: I34a73ec1c968a98a9fca649c65863aa43ca39ca8
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3461090
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
diff --git a/futility/updater_archive.c b/futility/updater_archive.c
index 93a043a..9c3a608 100644
--- a/futility/updater_archive.c
+++ b/futility/updater_archive.c
@@ -872,8 +872,10 @@
 			return NULL;
 		}
 
-		VB2_DEBUG("Matched chromeos-config index: %d\n", matched_index);
-		VB2_DEBUG("Manifest key (model): '%s'\n", manifest_key);
+		INFO("Identified the device using libcrosid, "
+		     "matched chromeos-config index: %d, "
+		     "manifest key (model): %s\n",
+		     matched_index, manifest_key);
 		model_name = manifest_key;
 	}
 
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index a846ef2..9f91129 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -528,6 +528,10 @@
 {
 	int r, i;
 
+	INFO("flasrhom -r <IMAGE> -p %s%s\n",
+	     image->programmer,
+	     verbosity ? " -V" : "");
+
 	for (i = 1, r = -1; i <= retries && r != 0; i++) {
 		if (i > 1)
 			WARN("Retry reading firmware (%d/%d)...\n", i, retries);
@@ -551,11 +555,24 @@
 {
 	int r, i;
 
+	INFO("flashrom -w <IMAGE> -p %s%s%s%s%s%s\n",
+	     image->programmer,
+	     diff_image ? " --flash-contents <DIFF_IMAGE>" : "",
+	     do_verify ? "" : " --noverify",
+	     verbosity > 1 ? " -V" : "",
+	     section_name ? " -i " : "",
+	     section_name ? section_name : "");
+
 	for (i = 1, r = -1; i <= retries && r != 0; i++) {
 		if (i > 1)
 			WARN("Retry writing firmware (%d/%d)...\n", i, retries);
 		r = flashrom_write_image(image, section_name, diff_image,
 					 do_verify, verbosity + 1);
+		/*
+		 * Force a newline to flush stdout in case if
+		 * flashrom_write_image left some messages in the buffer.
+		 */
+		fprintf(stdout, "\n");
 	}
 	return r;
 }
diff --git a/host/lib/flashrom_drv.c b/host/lib/flashrom_drv.c
index dfc9c83..18e00eb 100644
--- a/host/lib/flashrom_drv.c
+++ b/host/lib/flashrom_drv.c
@@ -102,7 +102,7 @@
 
 	image->data = calloc(1, len);
 	image->size = len;
-	image->file_name = strdup("<none>");
+	image->file_name = strdup("<sys-flash>");
 
 	r |= flashrom_image_read(flashctx, image->data, len);