Add flashmap (fmap) support to Flashrom
This adds flashmap parsing to Flashrom. If an fmap data structure is found, entries will be added to flashrom's internal rom layout.
BUG=chromium-os:115
TEST=Tested on Alex
Testing methodology is similar to what was used in the -i argument patch (git hash d0ea9e), except now fmap data was present in the original bios image:
- Partial write test (automated script)
- Manual partial reads test by reading 4K chunks from ROM and comparing against original BIOS image file and also inspecting the chip-sized file.
- Ensure final chip-size image is generated properly by omitting :file from one of the -i arguments.
- Full read if no -i options are used when fmap is present
- Entire chip written if no -i option is specified and fmap is present. Same holds true if a layout file is specified by no regions are included. A command like "flashrom -w bios.bin" or "flashrom -l layout.txt -w bios.bin" will consistently write the full image to ROM.
- Specifying a non-existent region caused flashrom to fail (expected result).
TODO: Automate all of the above.
Review URL: http://codereview.chromium.org/6025013
diff --git a/flashrom.c b/flashrom.c
index 436f8d3..5353f2a 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1897,6 +1897,12 @@
if (flash->unlock)
flash->unlock(flash);
+ /* add entries for regions specified in flashmap */
+ if (add_fmap_entries(flash) < 0) {
+ ret = 1;
+ goto out_nofree;
+ }
+
/* mark entries included using -i argument as "included" if they are
found in the master rom_entries list */
if (process_include_args() < 0) {