HACKSHACK_ LABS

Guides · 20 Oct 2026 · Documentation-based

SPI Flash Programming on Linux: Backups, flashrom and Safety

A practical, documentation-based introduction to SPI flash reading and CH341A programmer pitfalls.

A small eight-pin SPI NOR flash chip may hold a router’s firmware or a computer’s BIOS/UEFI image. Reading it before changing anything can be valuable for repair and research. But a cheap USB programmer is not automatically safe for every chip.

This guide describes a conservative workflow; HackShack Labs has not performed these steps on the advertised CH341A/B kit.

Know the hardware before connecting

Read the full chip marking and locate its datasheet. Confirm:

Some older black CH341A programmer boards have been reported to drive 5 V logic into nominally 3.3 V flash devices. Do not assume that an included 1.8 V adapter also translates all signal levels correctly. Verify the exact hardware revision.

Top view of a common 25-series SPI NOR SOIC8 pinout showing pin 1 orientation; verify the exact chip datasheet.

Diagram: Illustrative pin numbers only, not a universal programmer wiring guide. Confirm pinout, orientation and voltage in the exact chip datasheet before attaching a clip.

In-circuit clips have limitations

A SOIC8 clip can avoid desoldering, but other components connected to the SPI bus may load the signals, and a programmer may back-power the motherboard through protection diodes. Disconnect power and batteries where practical; do not connect a programmer to a powered board. Even an unpowered board can be unsuitable for in-circuit reading. If reads are inconsistent, stop and investigate rather than increasing voltage. Even three identical reads and matching hashes show only repeatability, not that an in-circuit image is valid.

Install flashrom

On Debian or Ubuntu:

sudo apt update
sudo apt install flashrom
flashrom --version

Check the flashrom programmer documentation for your exact adapter and current version. Distribution packages may lag behind upstream; newer flash chips can require a newer flashrom release. The following examples assume a compatible CH341A SPI programmer, an electrically safe connection and a supported chip.

Read twice, compare, keep the originals

sudo flashrom -p ch341a_spi
# Bash: fail the pipeline if flashrom fails, even when tee succeeds
set -o pipefail
sudo flashrom -V -p ch341a_spi -r backup-1.bin 2>&1 | tee flashrom-read-1.log
sudo flashrom -p ch341a_spi -r backup-2.bin
sha256sum backup-1.bin backup-2.bin
cmp backup-1.bin backup-2.bin

The first command only probes/detects the chip; do not proceed if the identification is ambiguous. Some chips share an identification value and flashrom can report several candidates: consult the markings and documentation, then use -c only for an independently confirmed exact chip model. Keep the verbose (-V) output with the backups. When using tee, check the flashrom exit status (set -o pipefail in Bash) rather than assuming the command succeeded.

Two identical reads are evidence of repeatability, not proof that the contents are valid. A third stable read can increase confidence in the connection, but identical hashes still do not establish firmware validity. Check the reported chip model, expected image size and any platform-specific structure. Store the original image safely, and document the board revision, chip markings, flashrom version and command output.

Do not start with a write

Writing the wrong image can make a device unbootable. Firmware images may contain device-specific data such as calibration values, MAC addresses, serial numbers or configuration. Do not flash an image merely because it has the correct size. Intel firmware descriptor regions, flash layouts and protected sections (--ifd and layout options) need separate, platform-specific treatment; they are outside this beginner read-only guide. Do not assume a full SPI dump is safe to write back. For an initial learning exercise, use a separate, known-compatible spare flash chip rather than an irreplaceable motherboard.

A backup may also contain secrets or identifying data. Store it securely and do not publish raw firmware dumps without checking rights, privacy and licensing.

Common failure modes

SymptomPossible cause
Chip not detectedWrong pinout, unsupported chip, voltage mismatch or poor clip contact
Different hashes on repeated readsUnreliable connection, in-circuit interference or unstable supply
Read succeeds but device will not boot after writeIncorrect image, missing board-specific data or failed verification
Unexpectedly warm chipDisconnect immediately; possible wiring or voltage fault

Continue learning: Follow the Electronics Fundamentals reading path for the complete sequence from multimeter basics through UART, I²C, SPI flash and logic analysis. Each guide distinguishes documentation from actual lab measurements.

Further reading

Editorial note: This is a documentation-based guide, not a test of a particular programmer. No product performance or safety certification is claimed.

Change history

  1. · Initial publication.