# Firmware Extraction Spi Flash Workflows

> Use when you need firmware off an SPI flash chip on an authorized assessment or in your own lab. Covers reading the chip in circuit with a test clip and reading it desoldered on a programmer, identifying the chip and its size, verifying each dump with hashes across repeated reads, handling write protect and in-circuit power problems, and handing a verified image to binwalk for carving. Also use when an update file is unavailable and the chip is the only firmware source.

- Skill: `mizazhaider-ceh/firmware-extraction-spi-flash-workflows` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/firmware-extraction-spi-flash-workflows`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/firmware-extraction-spi-flash-workflows/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/firmware-extraction-spi-flash-workflows

---


SPI flash is where most small embedded devices keep their firmware:
one 8-pin chip, a standard command set, and contents readable with a
cheap programmer. The work is not the read itself but proving the dump
is complete and trustworthy: the right chip selected, the whole chip
read, and repeated reads agreeing byte for byte. This sub-skill covers
both read paths, in circuit with a clip and desoldered on a
programmer, plus the verification discipline that separates a usable
image from a plausible looking corrupt one. Work only on devices you
own or have written permission to test, and never write to a chip on
a device you were only authorized to read.

## Quick Workflow

1. Identify the chip from its package markings and datasheet: vendor,
   part number, capacity, and voltage.
2. Decide the read path: clip in circuit when the board allows it,
   desoldered when in-circuit reads fail or the chip must be preserved.
3. For in-circuit reads, isolate the chip from the rest of the board
   as far as possible, and power it from the programmer, not the board.
4. Identify the chip with the programmer before reading anything.
5. Read the full chip at least twice to separate files and compare
   hashes.
6. Read a third time if the first two disagree, and investigate the
   cause before trusting any copy.
7. Store the verified dump read-only, with hashes recorded alongside.
8. Hand the verified image to binwalk for carving and filesystem
   extraction.

## 1. Identifying the chip and programmer setup

Read the markings under good light and magnification. Common SPI
flash markings include a vendor prefix, a capacity code, and a voltage
or speed suffix. Confirm capacity from the datasheet, not from the
marking alone, because similar markings cover different sizes. Set
the programmer voltage to the chip voltage, usually 3.3 V, and
confirm it before clipping on.

```bash
# List programmers flashrom can use on this machine
flashrom --list-programmers 2>&1 | head -20

# Identify the chip in circuit (read-only probe, changes nothing)
flashrom -p ch341a_spi -r /dev/null 2>&1 | head -20

# Identify a chip on a dedicated programmer socket instead
flashrom -p serprog:dev=/dev/ttyUSB0:400000 -r /dev/null 2>&1 | head -20
```

If flashrom reports multiple possible chips, force the exact part
number from the datasheet with the chip option rather than accepting
the first guess. A wrong chip definition can mean a wrong size, which
silently truncates the dump.

## 2. Reading in circuit with a test clip

In-circuit reads fail most often for one reason: the rest of the
board fights the programmer. The main processor may try to drive the
same bus, or board power may back-feed the programmer. Keep the board
unpowered, hold the main processor in reset where a reset test point
exists, and connect the clip with pin 1 aligned to the chip dot.

```bash
# Read the full chip twice to separate files
flashrom -p ch341a_spi -c "W25Q64.V" -r dump-a.bin 2>&1 | tee read-a.log
flashrom -p ch341a_spi -c "W25Q64.V" -r dump-b.bin 2>&1 | tee read-b.log

# Repeated reads must agree exactly before the dump is trusted
sha256sum dump-a.bin dump-b.bin
cmp dump-a.bin dump-b.bin && echo "reads agree - dump verified" \
  || echo "READS DIFFER - do not analyze yet, see edge cases"
```

```bash
# Record chip, size, and hashes next to the dump for the report
cat > dump-notes.txt <<'EOF'
chip - W25Q64.V (example, replace with the actual part number)
programmer - ch341a_spi
read path - in circuit, SOIC-8 test clip, board unpowered
verification - two independent reads, hashes compared
EOF
ls -l dump-a.bin dump-b.bin
sha256sum dump-a.bin | tee dump-a.sha256
```

Replace the chip name in these commands with the part number your
probe actually reported. The W25Q64.V name here is an example of the
command shape, not a claim about the chip on your board.

## 3. Reading desoldered on a programmer

When in-circuit reads disagree, the clip contact is poor, or the
board powers the bus, desoldering removes the whole class of
problems. Use hot air or a dedicated desoldering tool, keep the chip
temperature within the datasheet limits, and place it in the correct
socket adapter. Read it twice the same way as in circuit, and keep
the chip safe for re-soldering if the device must be returned to
service.

```bash
# Desoldered read, same verification discipline as in circuit
flashrom -p ch341a_spi -c "W25Q64.V" -r dump-desoldered-a.bin 2>&1 | tee read-des-a.log
flashrom -p ch341a_spi -c "W25Q64.V" -r dump-desoldered-b.bin 2>&1 | tee read-des-b.log
cmp dump-desoldered-a.bin dump-desoldered-b.bin \
  && echo "desoldered reads agree" || echo "READS DIFFER - investigate before use"
```

## 4. Verifying and carving the image

Only a verified dump goes to analysis. Check the size against the
datasheet capacity, look at the entropy and structure, then carve.

```bash
# Size must equal the datasheet capacity, not just look plausible
ls -l dump-a.bin
binwalk dump-a.bin 2>&1 | tee binwalk-scan.txt

# Extract carved parts into a working directory, original stays untouched
mkdir -p carved
binwalk -e -C carved dump-a.bin 2>&1 | tee binwalk-extract.log
find carved -type f | head -30
```

```python
#!/usr/bin/env python3
"""Sanity check a flash dump before carving: size, blank regions, headers."""
import sys

path = sys.argv[1]
data = open(path, "rb").read()
print(f"{path} - {len(data)} bytes ({len(data) // 1024} KiB)")
for name, pattern in [("all 0xff", b"\xff"), ("all 0x00", b"\x00")]:
    runs = 0
    i = 0
    while i < len(data):
        if data[i:i + 1] == pattern:
            j = i
            while j < len(data) and data[j:j + 1] == pattern:
                j += 1
            if j - i >= 4096:
                runs += 1
            i = j
        else:
            i += 1
    print(f"blank regions of 4 KiB or more filled with {name} - {runs}")
print(f"first 16 bytes - {data[:16].hex()}")
```

## Edge cases

- Reads disagree: suspect clip contact first. Reseat the clip, clean
  the pins, shorten the programmer leads, and read again before
  assuming chip damage.
- Board back-powers the programmer: if the board LEDs light when the
  programmer connects, disconnect immediately. Hold the processor in
  reset or move to the desoldered path.
- Write protect pin held active: reads still work with write protect
  asserted, so a read failure is not a write protect problem. Check
  contact and chip selection instead.
- Wrong capacity: a dump shorter than the datasheet size means the
  chip definition is wrong or the read truncated. A dump longer than
  the size means the definition is wrong in the other direction.
  Neither is safe to analyze.
- Dual and quad SPI parts: a plain SPI read still works on most
  dual and quad parts in single mode, but check the datasheet, since
  some parts need a mode command before the full array is visible.
- Chip responds but returns all 0xff: usually a disconnected MISO
  line or a chip held in reset, not an erased chip. Verify continuity
  on every clip lead.
- Soldered chip must be returned working: photograph the board
  before desoldering, note chip orientation, and re-solder with the
  same orientation. A reversed chip on power-up can destroy it.

## Key references

- The chip datasheet for the exact part on the board, especially the
  capacity, voltage, and command set tables.
- flashrom documentation, programmer options and chip selection.
- binwalk documentation, signature scanning and extraction options.
- The parent firmware-extraction skill for update package unpacking
  and filesystem extraction from verified images.

