summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2023-02-15 11:28:57 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-29 08:19:35 +0000
commit6a611a4c6b9a62a6f331fb8c9a67fc554dc59666 (patch)
tree31a29c9efb8d57b7fcd87de39858ff83a8cb4160
parent1945cbee1d5facfc3b8bb0908a83a3be11007341 (diff)
downloadvboot-6a611a4c6b9a62a6f331fb8c9a67fc554dc59666.tar.gz
futility: gbb: Avoid unnecessary search of FMAP
For commands such as `futility gbb --set --flags=0x140`, futility first reads the GBB section from the flash, modifies the section, and then writes back the section to the flash. The write, however, requires another search of the FMAP section, in order to locate the GBB section in the flash. This unnecessary search can be avoided by reading the FMAP section together with the GBB section. The FMAP data will be stored in the image buffer, so that the FMAP layout can be retrieved directly from the buffer for subsequent writes. This will also prevent the misleading warnings from showing up: Failed to read fmap from buffer. WARNING: flashrom_write_image: could not read fmap from image, r=1, falling back to read from rom BUG=b:260531154 TEST=emerge-corsola vboot_reference TEST=make runtests TEST=No warnings and errors were shown with `futility gbb --set --flash --flags=0x140` BRANCH=none Change-Id: I50029ae5d9c5ecb347f47e980e7c3b772ecc0f18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4251504 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4380993 Tested-by: Phoebe Wang <phoebewang@chromium.org> Reviewed-by: Cheng Yueh <cyueh@chromium.org> Auto-Submit: Phoebe Wang <phoebewang@chromium.org> Commit-Queue: Cheng Yueh <cyueh@chromium.org>
-rw-r--r--futility/cmd_gbb_utility.c6
-rw-r--r--futility/updater.h3
2 files changed, 7 insertions, 2 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c
index 95c1a47d..08b6591f 100644
--- a/futility/cmd_gbb_utility.c
+++ b/futility/cmd_gbb_utility.c
@@ -417,7 +417,11 @@ static void teardown_flash(struct updater_config *cfg,
static uint8_t *read_from_flash(struct updater_config *cfg, off_t *filesize)
{
#ifdef USE_FLASHROM
- const char * const regions[] = {FMAP_RO_GBB, NULL};
+ /*
+ * Read the FMAP region as well, so that a subsequet write won't
+ * require another read of FMAP.
+ */
+ const char * const regions[] = {FMAP_RO_FMAP, FMAP_RO_GBB, NULL};
if (flashrom_read_image(&cfg->image_current, regions,
cfg->verbosity + 1))
return NULL;
diff --git a/futility/updater.h b/futility/updater.h
index 788bf65f..3d04cb4e 100644
--- a/futility/updater.h
+++ b/futility/updater.h
@@ -12,7 +12,8 @@
#include "updater_utils.h"
/* FMAP section names. */
-static const char * const FMAP_RO_FRID = "RO_FRID",
+static const char * const FMAP_RO_FMAP = "FMAP",
+ * const FMAP_RO_FRID = "RO_FRID",
* const FMAP_RO_SECTION = "RO_SECTION",
* const FMAP_RO_CBFS = "COREBOOT",
* const FMAP_RO_GBB = "GBB",