1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-11-04 15:10:39 +01:00

cli-classic: Add new '--fmap-verify' option

Add a new layout option, --fmap-verify, to be used when writing to
flash, which will compare the FMAP on the flash chip to the one in
the file being flashed, and abort if there are any differences.
The comparison ensures that number of regions and start/end addresses
are all identical.

Add documentation for the new option as well.

TEST: tested with the following commands:
flashrom -p internal -r coreboot.rom --fmap-verify -i COREBOOT (fails w/error)
flashrom -p internal -v coreboot.rom --fmap-verify -i COREBOOT (fails w/error)
flashrom -p internal -r coreboot.rom --fmap -i COREBOOT (ok)
flashrom -p internal -w coreboot.rom --fmap-verify -i COREBOOT (fails w/error - no FMAP)
flashrom -p internal -r coreboot.rom (fails w/error, active ME)
flashrom -p internal -r coreboot.rom --ifd -i bios (ok)
flashrom -p internal -w coreboot.rom --fmap-verify -i COREBOOT -N (ok)

Change-Id: I34f69d848869cf236b7e57cf8f60c2aaad79c385
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/89536
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Matt DeVillier
2025-10-12 17:46:42 -05:00
committed by Anastasia Klimchuk
parent b0b975d0ea
commit bc3f2f84f9
4 changed files with 104 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ SYNOPSIS
| -p <programmername>[:<parameters>] [-c <chipname>]
| (--flash-name|--flash-size|
| [-E|-x|-r [<file>]|-w [<file>]|-v [<file>]]
| [(-l <file>|--ifd|--fmap|--fmap-file <file>)
| [(-l <file>|--ifd|--fmap|--fmap-file <file>|--fmap-verify)
| [-i <include>[:<file>]]]
| [--wp-status] [--wp-list] [--wp-enable|--wp-disable]
| [--wp-range <start>,<length>|--wp-region <region>]
@@ -179,6 +179,21 @@ All operations involving any chip access (probe/read/write/...) require the ``-p
flashrom -p prog --fmap-file some.rom --image COREBOOT -w some.rom
**--fmap-verify**
Read ROM layout from fmap embedded in the ROM and verify that it matches the fmap in the file to be written.
This option is mutually exclusive with **--fmap**, **--fmap-file**, **--layout**, and **--ifd**.
It can only be used with write operations, as it does not make sense otherwise. Before writing, **flashrom**
will read the fmap from both the flash chip and the file to be written, then compare them. If the fmaps do
not match, the write operation will be aborted.
This is useful to prevent accidentally writing a ROM image with an incompatible layout to a flash chip.
If you only want to update the **COREBOOT** region defined in the fmap, and verify that the fmap matches, run::
flashrom -p prog --fmap-verify -w new.rom --image COREBOOT
**--ifd**
Read ROM layout from Intel Firmware Descriptor.