summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Benn <evanbenn@chromium.org>2023-01-12 09:34:17 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-13 14:36:45 +0000
commitea185f1c07a88e96ad7bd664a97582559dc6e53f (patch)
treeb0fd013a1f58ee73964d4f2c9708018bba0649d1
parent16791bfe0f16f02d8be50c429e56fe46bfedda8e (diff)
downloadvboot-ea185f1c07a88e96ad7bd664a97582559dc6e53f.tar.gz
futility: cmd_read: Do not error on bad firmware format
Write the read firmware whether or not it can be parsed as a cros firmware. BUG=b:264810939 BRANCH=None TEST=futility read /dev/null Change-Id: Ia0fe2a6b9d9250dd05485d2f48c74a33a048ab21 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4158631 Reviewed-by: Hsuan Ting Chen <roccochen@chromium.org> Commit-Queue: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--futility/cmd_read.c7
-rw-r--r--futility/updater_utils.c8
-rw-r--r--futility/updater_utils.h3
3 files changed, 12 insertions, 6 deletions
diff --git a/futility/cmd_read.c b/futility/cmd_read.c
index e0c83616..e99264ae 100644
--- a/futility/cmd_read.c
+++ b/futility/cmd_read.c
@@ -104,7 +104,12 @@ static int do_read(int argc, char *argv[])
errorcnt += updater_setup_config(cfg, &args, &update_needed);
if (!errorcnt && update_needed) {
prepare_servo_control(prepare_ctrl_name, 1);
- if (load_system_firmware(cfg, &cfg->image_current))
+ int r = load_system_firmware(cfg, &cfg->image_current);
+ /*
+ * Ignore a parse error as we still want to write the file
+ * out in that case
+ */
+ if (r && r != IMAGE_PARSE_FAILURE)
errorcnt++;
prepare_servo_control(prepare_ctrl_name, 0);
}
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index 883b7027..8895c094 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -159,6 +159,10 @@ static int load_firmware_version(struct firmware_image *image,
return 0;
}
+/*
+ * Fills in the other fields of image using image->data.
+ * Returns IMAGE_LOAD_SUCCESS or IMAGE_PARSE_FAILURE.
+ */
static int parse_firmware_image(struct firmware_image *image)
{
int ret = IMAGE_LOAD_SUCCESS;
@@ -685,10 +689,6 @@ static int write_flash(struct flashrom_params *params,
return r;
}
-/*
- * Loads the active system firmware image (usually from SPI flash chip).
- * Returns 0 if success, non-zero if error.
- */
int load_system_firmware(struct updater_config *cfg,
struct firmware_image *image)
{
diff --git a/futility/updater_utils.h b/futility/updater_utils.h
index 953b91f0..a0dfc912 100644
--- a/futility/updater_utils.h
+++ b/futility/updater_utils.h
@@ -96,7 +96,8 @@ struct updater_config;
/*
* Loads the active system firmware image (usually from SPI flash chip).
- * Returns 0 if success, non-zero if error.
+ * Returns 0 if success. Returns IMAGE_PARSE_FAILURE for non-vboot images.
+ * Returns other values for error.
*/
int load_system_firmware(struct updater_config *cfg,
struct firmware_image *image);