Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17787
-gerrit
commit 9d65b9c9cfe8d18a4276f07e01373e901c3ffd4a Author: Patrick Georgi pgeorgi@google.com Date: Tue Dec 6 18:55:26 2016 +0100
util/cbfstool: Enable filling fmap regions with a given value
So far, cbfstool write, when used with the -u/-d options (to "fill upwards/downwards") left the parts of the region alone for which there was no new data to write.
When adding -i [0..255], these parts are overwritten with the given value.
BUG=chromium:595715 BRANCH=none TEST=cbfstool write -u -i 0 ... does the right thing (fill the unused space with zeroes)
Change-Id: I1b1c0eeed2862bc9fe5f66caae93b08fe21f465c Signed-off-by: Patrick Georgi pgeorgi@chromium.org Original-Commit-Id: baf378c5f2afdae9946600ef6ff07408a3668fe0 Original-Change-Id: I3752f731f8e6592b1a390ab565aa56e6b7de6765 Original-Signed-off-by: Patrick Georgi pgeorgi@google.com Original-Reviewed-on: https://chromium-review.googlesource.com/417319 Original-Commit-Ready: Patrick Georgi pgeorgi@chromium.org Original-Tested-by: Patrick Georgi pgeorgi@chromium.org Original-Reviewed-by: Stefan Reinauer reinauer@chromium.org --- util/cbfstool/cbfstool.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index c823dc8..6f85302 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -90,6 +90,7 @@ static struct param { .hash = VB2_HASH_INVALID, .headeroffset = ~0, .region_name = SECTION_NAME_PRIMARY_CBFS, + .u64val = -1, };
static bool region_is_flashmap(const char *region) @@ -980,8 +981,18 @@ static int cbfs_write(void) buffer_delete(&new_content); return 1; } - WARN("Written area will abut %s of target region: any unused space will keep its current contents\n", - param.fill_partial_upward ? "bottom" : "top"); + if (param.u64val == (uint64_t)-1) { + WARN("Written area will abut %s of target region: any unused space will keep its current contents\n", + param.fill_partial_upward ? "bottom" : "top"); + } else if (param.u64val > 0xff) { + ERROR("given fill value (%x) is larger than a byte\n", (unsigned)(param.u64val & 0xff)); + buffer_delete(&new_content); + return 1; + } else { + memset(buffer_get(param.image_region), + param.u64val & 0xff, + buffer_size(param.image_region)); + } if (param.fill_partial_downward) offset = param.image_region->size - new_content.size; } @@ -1089,7 +1100,7 @@ static const struct command commands[] = { {"read", "r:f:vh?", cbfs_read, true, false}, {"remove", "H:r:n:vh?", cbfs_remove, true, true}, {"update-fit", "H:r:n:x:vh?", cbfs_update_fit, true, true}, - {"write", "r:f:Fudvh?", cbfs_write, true, true}, + {"write", "r:f:i:Fudvh?", cbfs_write, true, true}, };
static struct option long_options[] = { @@ -1235,7 +1246,7 @@ static void usage(char *name) "Show the contents of the ROM\n" " extract [-r image,regions] [-m ARCH] -n NAME -f FILE " "Extracts a raw payload from ROM\n" - " write [-F] -r image,regions -f file [-u | -d] " + " write [-F] -r image,regions -f file [-u | -d] [-i int] " "Write file into same-size [or larger] raw region\n" " read [-r fmap-region] -f file " "Extract raw region contents into binary file\n"