flashrom
flashrom is a utility for detecting, reading, writing, verifying and erasing flash chips. It’s often used to flash BIOS/EFI/coreboot/firmware images in-system using a supported mainboard. However, it also supports various external PCI/USB/parallel-port/serial-port based devices which can program flash chips, including some network cards (NICs), SATA/IDE controller cards, graphics cards, the Bus Pirate device, various FTDI FT2232/FT4232H/FT4233H/FT232H based USB devices, and more.
Usage
Usage: “flashrom [options]`
| Option | Description |
|---|---|
-r, –read [<file>] | Read flash ROM contents and save them into the given <file>. If the file already exists, it will be overwritten. The <file> parameter is required unless reading is restricted to one or more flash regions via the -i/--include parameter and the file is specified there. See the —include section below for examples. |
-w, –write (<file>/-) | Write <file> into flash ROM. If - is provided instead, contents will be read from stdin. This will first automatically erase the chip, then write to it. During this process, the chip is read multiple times: an in-memory backup is made for disaster recovery and to skip regions already equal to the image file, and the copy is updated along with the write operation. In case of erase errors, it is re-read completely. After writing, if verification is enabled, the whole flash chip is read and compared with the input image. The <file> parameter is required unless writing is restricted via -i/--include and specified there. See the —include section below for examples. |
-n, –noverify | Skip the automatic verification of flash ROM contents after writing. Not recommended unless you know what you are doing and want to save time. Typical usage: flashrom -p prog -n -w <file>. Only useful in combination with --write. |
-N, –noverify-all | Skip not included regions during automatic verification after writing (cf. -l and -i). Use only if communication with the flash chip is reliable (e.g. internal programmer). Even if flashrom is not instructed to touch parts of the flash chip, their contents could be damaged. Required to flash an Intel system with locked ME flash region using the internal programmer; may be enabled by default in the future. |
-v, –verify (<file>/-) | Verify the flash ROM contents against the given <file>. If - is provided, contents will be written to stdout. The <file> parameter is required unless verification is restricted via -i/--include parameter and specified there. See the —include section below for examples. |
-E, –erase | Erase the flash ROM chip. |
-x, –extract | Extract every region defined on the layout from flash ROM chip to a file with the same name as the extracted region (replacing spaces with underscores). |
-V, –verbose | More verbose output. Can be supplied multiple times (max 3 times, e.g. -VVV) for more debug output. |
-c, –chip <chipname> | Probe only for the specified flash ROM chip. Takes the chip name as printed by flashrom -L without the vendor name. Chip name is case sensitive. |
-f, –force | Force one or more of the following actions: force chip read and pretend chip is present; force chip access even if bigger than supported size; force erase even if erase is known bad; force write even if write is known bad. |
–fmap | Read layout from fmap in flash chip. Supports coreboot fmap binary format to partition flash chip. Example: flashrom -p prog --fmap --image COREBOOT -w some.rom to update COREBOOT region. |
–fmap-file <file> | Read layout from a <file> containing binary fmap (e.g. coreboot ROMs). Supports fmap binary format for layout generation. Example: flashrom -p prog --fmap-file some.rom --image COREBOOT -w some.rom. |
–ifd | Read ROM layout from Intel Firmware Descriptor (IFD). The on-chip descriptor is read and used to generate layout. To change layout, update IFD first. ROM images in IFD may include: - fd (the IFD itself) - bios (host firmware aka BIOS) - me (Intel Management Engine firmware) - gbe (gigabit ethernet firmware) - pd (platform specific data) |
-i, –include <region>[:<file>] | Read, write, or verify only <region> to or from ROM. Can be used multiple times for multiple regions. Optionally specify a <file> per region. For read operations, regions are saved individually. For write operations, files are read and written to corresponding regions. If file parameter is used with -r/-w/-v and files are also specified for -i, -i files take priority. Rules govern filename usage and partial operations. Regions must not overlap. Examples:Read regions foo and bar: flashrom -p prog -r -l <layout> -i foo:foo.bin -i bar:bar.binWrite regions foo and bar: flashrom -p prog -w -l <layout> -i foo:foo.bin -i bar:bar.binVerify regions foo and bar: flashrom -p prog -v -l <layout> -i foo:foo.bin -i bar:bar.bin |
–wp-status | Prints the flash’s current status register protection mode and write protection range. |
–wp-list | Prints a list of all protection ranges that the flash supports. |
–wp-enable | Enables hardware status register protection (SRP) if the flash supports it. Once SRP is enabled, operations changing flash status registers (including --wp-disable and --wp-range) require flash’s WP pin at inactive logic level. |
–wp-disable | Disables status register protection if allowed. |
–wp-range <start>,<length> | Protects a range of addresses from <start> to <start> + <length> - 1, inclusive. Range must be supported by flash (see --wp-list). |
–wp-region <region> | Same as --wp-range but protects the range occupied by an image region. Requires image layout specified (--layout). Region must be supported by flash (see --wp-list). |
–flash-name | Prints out the detected flash chip’s name. |
–flash-size | Prints out the detected flash chip’s size. |
–flash-contents <ref-file> | Uses contents of <ref-file> to decide which parts of the flash need writing. Saves an initial read of full flash chip. Be careful: if data doesn’t match flash contents, results are undefined. |
-L, –list-supported | Lists flash chips, chipsets, mainboards, and external programmers supported by flashrom. Many unlisted boards may work out of the box. For verification, test ERASE/WRITE with means to recover from failure. |
-p, –programmer <name>[:parameter[,parameter[,parameter]]] | Specify the programmer device. Mandatory for all chip access operations. Supported programmers include: internal, dummy, nic3com, nicrealtek, nicnatsemi, nicintel, gfxnvidia, drkaiser, satasii, satamv, atahpt, atavia, atapromise, it8212, ft2232_spi, serprog, buspirate_spi, dediprog, rayer_spi, raiden_debug_spi, pony_spi, nicintel_spi, ogp_spi, linux_mtd, linux_spi, usbblaster_spi, nicintel_eeprom, mstarddc_spi, pickit2_spi, ch341a_spi, ch347_api, digilent_spi, jlink_spi, ni845x_spi, stlinkv3_spi, realtek_mst_i2c_spi, parade_lspcon, mediatek_i2c_spi, dirtyjtag_spi, asm106x, spidriver. Some have optional or mandatory parameters. Support may be disabled at compile time. flashrom -h lists all supported programmers. |
-h, –help | Show a help text and exit. |
-o, –output <logfile> | Save the full debug log to <logfile>. If the file exists, it will be overwritten. Recommended for gathering verbose logs without output redirection. |
–progress | Show progress percentage of operations on standard output. |
–sacrifice-ratio <ratio> | Fraction (percentage 0–50) of an erase block that may be erased even if unmodified. Larger values may speed programming but reduce chip longevity. Default is 0 (only erase larger block if all smaller blocks inside it need erase). 50 means if more than half area needs erase, erase the larger block. Tradeoff between speed and chip longevity. DANGEROUS! It wears your chip faster! |
-R, –version | Show version information and exit. |
Examples
# Read BIOS/Firmware to a File
flashrom -p internal -r backup.rom
# Write a New Firmware Image
flashrom -p internal -w new_firmware.rom
# Verify Flash Contents
flashrom -p internal -v new_firmware.rom
# Erase Flash Chip
flashrom -p internal -E