ESP32 Bit Pirate home
  • SPI Flash
  • Advanced
  • 10 min
  • Flashrom

Recipe · Advanced · SPI

How to write a SPI flash image with Flashrom

The Flashrom adapter exposes a serprog-compatible programmer over USB CDC. The adapter wiki documents read, probe and write examples for external SPI NOR flash chips.

Firmware repair workflow with backup files.
Write is the last step: probe, backup, confirm image, then flash and verify.

Wiring View

Flash chip BP adapter CS#CS GPIOCLKSCK GPIODO / IO1MISO GPIODI / IO0MOSI GPIOGNDGNDVCCcorrect flash s...
Generated from the wiring summary: Flash chip to BP adapter.
Step 1

Commands

Run the host commands from your computer against the adapter serial port.

Safe write order

  1. Put the firmware in Flashrom SPI adapter mode and let it reboot into the USB CDC adapter.
  2. Probe with verbose output before writing.
  3. Read a backup and store it somewhere safe.
  4. Write the known-good image and let Flashrom verify it.
  5. Power-cycle the target only after the write/verify step completes.

Result

What success looks like

Flashrom identifies the chip, writes the image and completes verification. Keep the backup even after the board boots again.

Troubleshooting

  • Flashrom cannot identify the chip: check CS, MISO/MOSI, power and WP#/HOLD#.
  • Write fails in-circuit: the main board may still be driving the SPI bus.
  • Image size does not match the detected flash size.
  • Clip contact is unstable during erase/write.

Next steps

  • Use flashrom -r verify.bin and compare files if you want an extra verification read.
  • Use the browser SPI Flash Programmer for a simpler UI.
  • Use the SPI flash shell for quick read/search/analyze tasks from the firmware CLI.

SPI flash Flashrom write FAQ

Why should I read a backup before writing?

A backup is the only easy path back if the image is wrong, the target has board-specific calibration data, or the write fails halfway. Read and keep the original before erase or write.

Why must the image size match the detected flash size?

A full-chip write replaces the address space Flashrom detected. Matching the image size to the chip size prevents accidental truncation, padding mistakes and firmware images being written to the wrong target.

What if Flashrom verifies but the board still does not boot?

A successful verify only proves the bytes were written back as requested. The image can still be for the wrong board, miss calibration or partition data, or require a different boot configuration.

Go deeper