Flashrom
From Leo's Notes
This page was last edited on 18 December 2021, at 04:36.
Flashrom is a utility to read flash.
Cheat sheet
| Task | Command |
|---|---|
| Dump a ROM connected via SPI | flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r dump.bin
|
| Dump a ROM via SPI using a specific chip definition | flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=600 -c "MX25L12835F/MX25L12845E/MX25L12865E" -w dump.bin
|
| Write a ROM via SPI | flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w new-data-to-rom.bin
|
Using flashrom with a Raspberry Pi
Pinouts

Refer to the table below and the diagram on the right for the pinouts to your Raspberry Pi and the SPI rom device.
| RPi header | SPI Function | MX25L 16-Pin SOP | HM25Q 8-Pin SOP |
|---|---|---|---|
| 25 | GND | 10 | 4 |
| 24 | CS | 7 | 1 |
| 23 | SCK (CLK) | 16 | 6 |
| 21 | DO (MISO) | 8 | 2 |
| 19 | DI (MOSI) | 15 | 5 |
| 17 | VCC 3.3v | 2 | 8 |
| WP# | 9 | 3 | |
| HOLD# / RESET# | 3 | 7 |
The MX25L - WriteProtect (WP#, pin 9) should be connected to GND according to the datasheet. Leaving it floating still seems to work.
The Raspberry Pi should have SPI enabled by adding this line to /boot/config.txt:
device_tree_param=spi=on
The /dev/spidev0.0 device should exist and flashrom should be able to detect the flash chip.
[root@alarmpi alarm]# flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=1000
flashrom v1.0 on Linux 4.14.92-1-ARCH (armv7l)
flashrom is free software, get the source code at https://flashrom.org
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Macronix flash chip "MX25L12805D" (16384 kB, SPI) on linux_spi.
Found Macronix flash chip "MX25L12835F/MX25L12845E/MX25L12865E" (16384 kB, SPI) on linux_spi.
Multiple flash chip definitions match the detected chip(s): "MX25L12805D", "MX25L12835F/MX25L12845E/MX25L12865E"
Please specify which chip definition to use with the -c <chipname> option.
Dump the data using -r filename.
[root@alarmpi alarm]# flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=300 -c "MX25L12835F/MX25L12845E/MX25L12865E" -r dump7.dat
flashrom v1.0 on Linux 4.14.92-1-ARCH (armv7l)
flashrom is free software, get the source code at https://flashrom.org
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Macronix flash chip "MX25L12835F/MX25L12845E/MX25L12865E" (16384 kB, SPI) on linux_spi.
Reading flash... done.