summaryrefslogtreecommitdiff
path: root/futility/updater_utils.c
diff options
context:
space:
mode:
authorSam McNally <sammc@chromium.org>2022-10-18 20:34:42 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-17 09:24:41 +0000
commit5b6985240bc5e673ec2a744bedda7e22583cea77 (patch)
tree788d562a3396094daf65e3daa5f065c2d0dba5ee /futility/updater_utils.c
parent69d6d85c20910cc1d07752c9468f7822d421339e (diff)
downloadvboot-5b6985240bc5e673ec2a744bedda7e22583cea77.tar.gz
futility: updater: Use flashrom dummy programmer to implement --emulate
futility update --emulate and flashrom's dummy programmer serve similar purposes - both provide support for using a file instead of a real ROM. The current --emulate implementation involves special-casing before interacting with flashrom and pre-filling in the current image contents; an appropriately-configured dummy programmer and unmodified flashrom interactions could accomplish the same outcome with a more centralised handling of --emulate. Other --emulate interactions mock out non-flashrom interactions, so need to continue handling --emulate specially for now. Switch --emulate to use the dummy programmer. Add an extra field to store the original programmer option for deciding on whether the apply the preserve_me quirk. BUG=b:253966060 TEST=unit tests BRANCH=None Signed-off-by: Sam McNally <sammc@chromium.org> Change-Id: I687749523f54edcb9dd41cfc85614949b9d6607a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3965582 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'futility/updater_utils.c')
-rw-r--r--futility/updater_utils.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index af94690a..a41c4038 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -618,61 +618,6 @@ static char *get_flashrom_command(enum flash_command flash_cmd,
return cmd;
}
-/*
- * Emulates writing a firmware image to the system.
- * Returns 0 if success, non-zero if error.
- */
-static int emulate_write_firmware(const char *filename,
- const struct firmware_image *image,
- const char * const sections[])
-{
- int i, errorcnt = 0;
- struct firmware_image to_image = {0};
-
- INFO("Writing from %s to %s (emu=%s).\n",
- image->file_name, image->programmer, filename);
-
- if (load_firmware_image(&to_image, filename, NULL)) {
- ERROR("Cannot load image from %s.\n", filename);
- return -1;
- }
-
- if (image->size != to_image.size) {
- ERROR("Image size is different (%s:%d != %s:%d)\n",
- image->file_name, image->size, to_image.file_name,
- to_image.size);
- errorcnt++;
- goto exit;
- }
-
- if (!sections) {
- VB2_DEBUG(" - write the whole image.\n");
- memmove(to_image.data, image->data, image->size);
- }
- for (i = 0; sections && sections[i]; i++) {
- VB2_DEBUG(" - write the section: %s.\n", sections[i]);
- if (preserve_firmware_section(image, &to_image, sections[i])) {
- ERROR("Failed to write the section: %s\n", sections[i]);
- errorcnt++;
- /*
- * Exit the loop, but still write the file to reflect
- * the partial changes - same as real flashrom behavior.
- */
- break;
- }
- }
-
- if (vb2_write_file(filename, to_image.data, to_image.size)) {
- ERROR("Failed writing to file: %s\n", filename);
- errorcnt++;
- goto exit;
- }
-
-exit:
- free_firmware_image(&to_image);
- return errorcnt;
-}
-
static int external_flashrom(enum flash_command flash_cmd,
struct flashrom_params *params,
struct tempfile *tempfiles)
@@ -796,9 +741,6 @@ int write_system_firmware(struct updater_config *cfg,
struct flashrom_params params = {0};
struct firmware_image *flash_contents = NULL;
- if (cfg->emulation)
- return emulate_write_firmware(cfg->emulation, image, sections);
-
if (cfg->use_diff_image && cfg->image_current.data &&
is_the_same_programmer(&cfg->image_current, image))
flash_contents = &cfg->image_current;