Flashrom: Difference between revisions
Initial Content |
mNo edit summary |
||
| Line 18: | Line 18: | ||
== Using flashrom with a Raspberry Pi == | == Using flashrom with a Raspberry Pi == | ||
[[File:Raspberry Pi GPIO Header.png|alt=Raspberry Pi GPIO Header|thumb|731x731px|Raspberry Pi GPIO Header]] | [[File:Raspberry Pi GPIO Header.png|alt=Raspberry Pi GPIO Header|thumb|731x731px|Raspberry Pi GPIO Header]] | ||
{| class="wikitable | {| class="wikitable" | ||
!RPi header!!SPI flash!!MX25L Pin | !RPi header!!SPI flash!!MX25L Pin | ||
|- | |- | ||
Revision as of 04:24, 18 December 2021
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

| RPi header | SPI flash | MX25L Pin |
|---|---|---|
| 25 | GND | 10 |
| 24 | CS | 7 |
| 23 | SCK (CLK) | 16 |
| 21 | DO (MISO) | 8 |
| 19 | DI (MOSI) | 15 |
| 17 | VCC 3.3v | 2 |
To read the chip using a Raspberry Pi and flashrom, we can use 1x serial IO by connecting the pins according to this table:
The WriteProtect (WP#, pin 9) should be connected to GND according to the datasheet. Leaving it floating still seems to work.
Refer to the Raspberry Pi pinout at https://i.stack.imgur.com/eLPtx.png.
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.