From f1144f4c25a38a78df7ac302f834d446270428e7 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Mon, 14 Feb 2022 19:02:24 +0800 Subject: futility: updater: improve updater console output To help debugging: - Print equivalent flashrom commands when reading and writing. - Print instead of 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3461090 Reviewed-by: Yu-Ping Wu Commit-Queue: Yu-Ping Wu --- futility/updater_archive.c | 6 ++++-- futility/updater_utils.c | 17 +++++++++++++++++ host/lib/flashrom_drv.c | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/futility/updater_archive.c b/futility/updater_archive.c index 93a043a9..9c3a608d 100644 --- a/futility/updater_archive.c +++ b/futility/updater_archive.c @@ -872,8 +872,10 @@ const struct model_config *manifest_find_model(const struct manifest *manifest, 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 a846ef2b..9f91129e 100644 --- a/futility/updater_utils.c +++ b/futility/updater_utils.c @@ -528,6 +528,10 @@ int load_system_firmware(struct firmware_image *image, { int r, i; + INFO("flasrhom -r -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 write_system_firmware(const struct firmware_image *image, { int r, i; + INFO("flashrom -w -p %s%s%s%s%s%s\n", + image->programmer, + diff_image ? " --flash-contents " : "", + 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 dfc9c83d..18e00ebe 100644 --- a/host/lib/flashrom_drv.c +++ b/host/lib/flashrom_drv.c @@ -102,7 +102,7 @@ int flashrom_read_image(struct firmware_image *image, const char *region, image->data = calloc(1, len); image->size = len; - image->file_name = strdup(""); + image->file_name = strdup(""); r |= flashrom_image_read(flashctx, image->data, len); -- cgit v1.2.1