diff options
author | Patrick Georgi <pgeorgi@google.com> | 2017-09-19 14:39:58 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2017-09-20 13:45:00 +0000 |
commit | 5d982d72be849a15f98bb0583b25bbcd6eb7d315 (patch) | |
tree | 5b0bc89e9b444d5fc295a9f6e275cdcf7618bffc /util/cbfstool/cbfstool.c | |
parent | bea2d75f3174a8fbd24be2010977f975e7a16720 (diff) |
util/cbfstool: Add "expand" command to make CBFS span an fmap region
vboot images come with multiple regions carrying CBFS file systems. To
expedite hashing (from slow flash memory), the FW_MAIN_* regions are
truncated since they typically have pretty large unused space at the
end that is of no interest.
For test purposes it can be useful to re-engage that space, so add a
command that creates a new empty file entry covering that area (except
for the last 4 bytes for the master header pointer, as usual).
BUG=b:65853903
BRANCH=none
TEST=`cbfstool test.bin expand -r FW_MAIN_A` creates a new empty file of
the expected size on a Chrome OS firmware image.
Change-Id: I160c8529ce4bfcc28685166b6d9035ade4f6f1d1
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/21598
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r-- | util/cbfstool/cbfstool.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index cc317515f7..5e7d904151 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -1107,6 +1107,20 @@ static int cbfs_compact(void) return cbfs_compact_instance(&image); } +static int cbfs_expand(void) +{ + struct buffer src_buf; + + /* Obtain the source region. */ + if (!partitioned_file_read_region(&src_buf, param.image_file, + param.region_name)) { + ERROR("Region not found in image: %s\n", param.source_region); + return 1; + } + + return cbfs_expand_to_region(param.image_region); +} + static const struct command commands[] = { {"add", "H:r:f:n:t:c:b:a:yvA:gh?", cbfs_add, true, true}, {"add-flat-binary", "H:r:f:n:l:e:c:b:vA:gh?", cbfs_add_flat_binary, @@ -1127,6 +1141,7 @@ static const struct command commands[] = { {"remove", "H:r:n:vh?", cbfs_remove, true, true}, {"update-fit", "H:r:n:x:vh?", cbfs_update_fit, true, true}, {"write", "r:f:i:Fudvh?", cbfs_write, true, true}, + {"expand", "r:h?", cbfs_expand, true, true}, }; static struct option long_options[] = { @@ -1276,6 +1291,8 @@ static void usage(char *name) "Write file into same-size [or larger] raw region\n" " read [-r fmap-region] -f file " "Extract raw region contents into binary file\n" + " expand [-r fmap-region] " + "Expand CBFS to span entire region\n" " update-fit [-r image,regions] -n MICROCODE_BLOB_NAME \\\n" " -x EMTPY_FIT_ENTRIES " "Updates the FIT table with microcode entries\n" |