# Hardware Reversing Bus Protocol Analysis

> Use when chips on a board talk to each other over SPI, I2C, or UART and you need to see what they say on an authorized assessment or in your own lab. Covers picking the right capture tool, wiring a logic analyzer without disturbing the bus, decoding captures into readable transactions, spotting firmware reads, sensor polls, and plaintext secrets, and correlating bus traffic with boot behavior. Also use when firmware extraction is blocked and the bus is the only readable path.

- Skill: `mizazhaider-ceh/hardware-reversing-bus-protocol-analysis` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/hardware-reversing-bus-protocol-analysis`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/hardware-reversing-bus-protocol-analysis/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/hardware-reversing-bus-protocol-analysis

---


Chips on a board rarely keep secrets from each other: a processor
reads firmware from SPI flash, polls sensors over I2C, and talks to
radios and debug ports over UART, usually in plaintext. Watching the
bus turns those conversations into evidence: what is read at boot,
which registers are configured, and where secrets cross the board in
the clear. This sub-skill covers capturing each bus cleanly, decoding
captures into transactions a human can read, and correlating traffic
with what the device is doing. Work only on boards you own or have
written permission to test, and clip on with the board powered down
whenever the probe points allow it.

## Quick Workflow

1. Identify the bus and its pins from labels, chip datasheets, and
   continuity: SPI needs clock, MOSI, MISO, and chip select; I2C
   needs SDA and SCL; UART needs TX and RX.
2. Measure the bus voltage and set the logic analyzer threshold to
   match it.
3. Connect the analyzer ground to board ground first, then the
   signal probes, keeping leads short.
4. Capture a short pilot during boot and confirm the decode looks
   sane before a long capture.
5. Capture the operation of interest: boot, a command, a sensor
   read, or a firmware update.
6. Decode the capture into transactions and export a readable log.
7. Correlate transactions with device behavior using timestamps and
   trigger markers.
8. Record pinout, voltage, sample rate, decoder settings, and
   findings with example transactions quoted.

## 1. Capturing SPI without disturbing the bus

SPI is the highest value bus on most boards because it usually
carries firmware reads. Probe at the flash chip pins or at series
resistors where they exist, and keep probe leads short, since long
leads add capacitance that can corrupt fast edges. Sample at least
10 times the bus clock where the analyzer allows it.

```bash
# List analyzers visible to the capture tool
sigrok-cli --list-devices 2>&1 | head -20

# Pilot capture: 5 seconds at 10 MHz, SPI decode on the fly
sigrok-cli --driver fx2lafw --config samplerate=10M \
  --channels MOSI=0,MISO=1,SCK=2,CS=3 \
  --protocol-decoders spi:mosi=0:miso=1:sck=2:cs=3 \
  --time 5s -o spi-pilot.sr 2>&1 | tee spi-pilot.log

# Longer boot capture, saved for offline decoding
sigrok-cli --driver fx2lafw --config samplerate=10M \
  --channels MOSI=0,MISO=1,SCK=2,CS=3 \
  --time 30s -o spi-boot.sr 2>&1 | tee spi-boot.log
```

Read the pilot decode before trusting the long capture: flash read
commands (opcode 0x03) followed by address bytes and data are the
signature of a sane SPI capture. Garbage decodes usually mean a
wrong channel assignment or a sample rate too low for the clock.

## 2. Decoding I2C transactions into readable form

I2C is slower and easier to capture, but its value is in the
addresses: each 7-bit address identifies a chip, and each register
write configures something. Decode to a transaction list of address,
read or write direction, register, and data, then map addresses to
chips from their datasheets.

```bash
# I2C capture and decode: SDA on channel 0, SCL on channel 1
sigrok-cli --driver fx2lafw --config samplerate=1M \
  --channels SDA=0,SCL=1 \
  --protocol-decoders i2c:sda=0:scl=1 \
  --time 10s -o i2c-capture.sr 2>&1 | tee i2c-capture.log

# Export the decode as text for analysis and reporting
sigrok-cli -i i2c-capture.sr \
  --protocol-decoders i2c:sda=0:scl=1 \
  -P i2c -A i2c=address-data 2>&1 | head -100 > i2c-transactions.txt
cat i2c-transactions.txt
```

```python
#!/usr/bin/env python3
"""Summarize I2C transactions by device address from a decode export.

Expects one transaction per line containing an address field in the
form 'address 0x48'. Adjust the parsing to the exact export format
of the decoder in use.
"""
import re
from collections import Counter

counts = Counter()
with open("i2c-transactions.txt") as fh:
    for line in fh:
        match = re.search(r"address 0x([0-9a-fA-F]+)", line)
        if match:
            counts[match.group(1).lower()] += 1

print("transactions per I2C address:")
for address, count in sorted(counts.items()):
    print(f"  0x{address} - {count} transactions")
```

## 3. Capturing and reading UART traffic

UART needs no clock line, which makes it the easiest bus to capture
and the easiest to get wrong: a wrong baud rate produces garbage
that looks like data. Capture at several common baud rates during a
pilot, and keep the rate that produces readable boot text.

```bash
# Try common baud rates against the suspected TX pin, one at a time
for baud in 115200 57600 38400 9600 230400; do
  echo "=== baud $baud ==="
  timeout 5 picocom -b $baud --imap lfcrlf /dev/ttyUSB0 2>/dev/null | head -5
done

# Log a full boot at the baud rate that produced readable text
picocom -b 115200 --imap lfcrlf --logfile uart-boot.log /dev/ttyUSB0
```

```python
#!/usr/bin/env python3
"""Scan a UART log for lines that deserve a closer look."""
import re

patterns = {
    "password or key material": re.compile(r"pass|key|token|secret", re.I),
    "bootloader prompt": re.compile(r"U-Boot|bootloader|=>\s*$", re.I),
    "error or failure": re.compile(r"error|fail|timeout|panic", re.I),
    "network address": re.compile(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"),
}

with open("uart-boot.log") as fh:
    for lineno, line in enumerate(fh, 1):
        for label, pattern in patterns.items():
            if pattern.search(line):
                print(f"line {lineno} [{label}] - {line.rstrip()}")
                break
```

## 4. Correlating bus traffic with boot behavior

A transaction list without timing is hard to interpret. Mark the
moments that matter: power on, bootloader start, kernel start, and
application start. On SPI, the first flash reads after power on are
the bootloader fetch. On I2C, the first writes after boot are
usually peripheral configuration. Compare a capture from a normal
boot with a capture from the operation under test, and the
difference is the traffic that operation caused.

```bash
# Compare transaction counts between a normal boot and a test run
wc -l i2c-transactions.txt spi-pilot.log
echo "--- look for addresses or opcodes present in one capture only ---"
grep -o "address 0x[0-9a-fA-F]*" i2c-transactions.txt | sort | uniq -c | sort -rn | head -20
```

## Edge cases

- Wrong logic threshold: a 1.8 V bus probed with a 3.3 V threshold
  reads as silence. Match the threshold to the measured bus voltage.
- Long probe leads corrupt fast SPI: shorten leads, probe at the
  chip pins, and drop the sample rate expectation before blaming
  the decode.
- Chip select confusion on shared buses: several chips can share
  MOSI, MISO, and clock with separate chip selects. Capture all chip
  selects or the decode will mix transactions from different chips.
- I2C clock stretching: some targets hold SCL low while busy. A
  decoder that assumes a fixed clock will misread these. Use a
  decoder that handles stretching, and check stretched regions by
  hand.
- UART baud mismatch: garbage at every tried rate can mean an
  unusual rate, inverted logic, or a TX pin that is not actually
  transmitting. Check the pin with an oscilloscope before trying
  more rates.
- Encrypted or compressed bus data: not every bus carries plaintext.
  High entropy payloads that resist decoding may be encrypted or
  compressed. Report the entropy and the structure, not a guessed
  plaintext.
- Probing changes behavior: a probe load can slow an edge enough to
  break a marginal bus. If the device behaves differently with
  probes attached, note it and prefer non-invasive points such as
  series resistors.

## Key references

- Chip datasheets for every part on the bus, especially the command
  and register tables.
- The logic analyzer decoder documentation for SPI, I2C, and UART
  protocol decoders.
- The parent hardware-reversing skill for board teardown and the
  full device analysis workflow.
- The parent uart-jtag skill for UART console access once a console
  is identified.

