summaryrefslogtreecommitdiffstats
path: root/util/cbfstool/fmap_from_fmd.c
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2019-03-04 15:41:09 +0800
committerPatrick Georgi <pgeorgi@google.com>2019-03-05 20:51:39 +0000
commit49a44505637ecfa3a6c1606bc0986e70397966b0 (patch)
tree3af3d1ace358e80e1a9f660a49db5215f4972f05 /util/cbfstool/fmap_from_fmd.c
parent44b4ec740db6dafed432a411506bfd7975a221f8 (diff)
downloadcoreboot-49a44505637ecfa3a6c1606bc0986e70397966b0.tar.gz
coreboot-49a44505637ecfa3a6c1606bc0986e70397966b0.tar.bz2
coreboot-49a44505637ecfa3a6c1606bc0986e70397966b0.zip
cbfstool: Support new FMD flag "PRESERVE"
When updating firmware, it is very often that we may want to preserve few sections, for example vital product data (VPD) including serial number, calibration data and cache. A firmware updater has to hard-code the section names that need to be preserved and is hard to maintain. A better approach is to specify that in FMAP area flags (the `area_flag` field) using FMAP_AREA_PRESERVE. With this patchset, a FMD parser flag "PRESERVE" is introduced and will be converted to FMAP_AREA_PRESERVE when generating FMAP data (by fmap_from_fmd.c). For example, The FMD statement: RO_VPD(PRESERVE)@0x0 16k will generate an FMAP firmware section that: area_name = "RO_VPD" area_offset = 0 area_size = 16384 area_flags = FMAP_AREA_PRESERVE BUG=chromium:936768 TEST=make; boots on x86 "google/eve" and arm "google/kukui" devices Manually added 'PRESERVE' to some FMD files, and verify (by running fmap.py) the output coreboot.rom has FMAP_AREA_PRESERVE set Change-Id: I51e7d31029b98868a1cab0d26bf04a14db01b1c0 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31707 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util/cbfstool/fmap_from_fmd.c')
-rw-r--r--util/cbfstool/fmap_from_fmd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/cbfstool/fmap_from_fmd.c b/util/cbfstool/fmap_from_fmd.c
index 5e3ec89ec1d1..374667a373a0 100644
--- a/util/cbfstool/fmap_from_fmd.c
+++ b/util/cbfstool/fmap_from_fmd.c
@@ -23,6 +23,7 @@
static bool fmap_append_fmd_node(struct fmap **flashmap,
const struct flashmap_descriptor *section,
unsigned absolute_watermark) {
+ uint16_t flags = 0;
if (strlen(section->name) >= FMAP_STRLEN) {
ERROR("Section name ('%s') exceeds %d character FMAP format limit\n",
section->name, FMAP_STRLEN - 1);
@@ -31,8 +32,11 @@ static bool fmap_append_fmd_node(struct fmap **flashmap,
absolute_watermark += section->offset;
+ if (section->flags.f.preserve)
+ flags |= FMAP_AREA_PRESERVE;
+
if (fmap_append_area(flashmap, absolute_watermark, section->size,
- (uint8_t *)section->name, 0) < 0) {
+ (uint8_t *)section->name, flags) < 0) {
ERROR("Failed to insert section '%s' into FMAP\n",
section->name);
return false;