# Uart Jtag Swd Probing

> Use when you need SWD-only debug access to an ARM target on an authorized assessment or in your own lab. Covers telling SWD apart from JTAG, finding SWDIO, SWCLK, GND, and Vref with a multimeter, building an OpenOCD adapter config, reading DP and AP registers, halting the core, and dumping memory regions you are authorized to read. Also use when a JTAG scan finds nothing but the board still exposes a two-wire debug header.

- Skill: `mizazhaider-ceh/uart-jtag-swd-probing` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/uart-jtag-swd-probing`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/uart-jtag-swd-probing/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/uart-jtag-swd-probing

---


SWD is the two-wire debug port ARM cores actually ship with: one data
line (SWDIO), one clock line (SWCLK), plus ground and a voltage
reference. Many boards that show no JTAG chain still answer on SWD,
because SWD needs fewer pins and survives on small headers and test
points. This sub-skill covers the SWD-only path in depth: telling the
two protocols apart, identifying the pins without a schematic,
confirming the connection with DP and AP register reads, and dumping
memory once the core is halted. Work only on hardware you own or have
written permission to test, and never connect a debug adapter to a
board whose supply voltage you have not measured.

## Quick Workflow

1. Measure the board supply voltage and confirm the debug header voltage
   before connecting any adapter.
2. Identify GND with continuity to a known ground point, then find Vref
   on the header (usually 3.3 V or 1.8 V).
3. Narrow the remaining pins to SWDIO and SWCLK by continuity, labeling,
   and elimination.
4. Connect the adapter with GND first, then Vref, SWDIO, and SWCLK.
   Leave the target reset line disconnected unless you need it.
5. Run an OpenOCD SWD scan and confirm the DP IDCODE reads back a
   plausible value.
6. Read the AP registers to confirm the access port and memory access
   path are present.
7. Halt the core, then dump only the memory regions in scope.
8. Record the pinout, adapter speed, IDCODE, and every dump hash.

## 1. Telling SWD apart from JTAG

JTAG needs at least TCK, TMS, TDI, and TDO plus ground. SWD needs only
SWDIO and SWCLK. A two-pin or three-pin debug footprint, or a header
where only two signal pins show activity during boot, points to SWD.
Some headers are dual purpose: the same pins carry JTAG when a mode
pin is strapped one way and SWD the other. If an OpenOCD JTAG scan
returns no devices but the chip is an ARM Cortex-M, try SWD before
concluding the port is disabled.

```bash
# JTAG scan first, so an empty result is evidence rather than a guess
openocd -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg \
  -c "init" -c "scan_chain" -c "shutdown" 2>&1 | head -20

# Then the same adapter in SWD mode against the same header
openocd -f interface/cmsis-dap.cfg \
  -c "transport select swd" \
  -c "adapter speed 1000" \
  -c "init" -c "dap info 0" -c "shutdown" 2>&1 | head -30
```

A healthy SWD link prints a DP IDCODE. A value of all zeros means no
connection or no power. A value of all ones usually means the data line
is pulled high with nothing driving it, which points to a wrong pin or
a missing ground.

## 2. Identifying the pins without a schematic

Work with the board unpowered for continuity tests and powered only
for voltage checks. Never probe continuity on a powered board.

```bash
# Log your pin map as you go, so a second session does not redo the work
cat > swd-pinmap.txt <<'EOF'
# header pin - measurement - conclusion
# pin 1 - 3.3 V to GND, powered - Vref candidate
# pin 2 - continuity to USB shield - GND
# pin 3 - no continuity to GND or Vref - SWDIO or SWCLK candidate
# pin 4 - no continuity to GND or Vref - SWDIO or SWCLK candidate
EOF
cat swd-pinmap.txt
```

Practical order: GND is the pin with continuity to shields, mounting
holes, and large ground pours. Vref reads the board supply voltage
when powered. The two remaining signal pins are SWDIO and SWCLK in
some order. If the first pairing fails, swap them and retry; a swap
cannot damage a 3.3 V tolerant adapter, but a wrong voltage can, so
confirm Vref first and set the adapter to match it.

## 3. OpenOCD SWD adapter configuration

Keep a small per-target config file instead of retyping commands.
The transport line is the part that matters: it forces SWD instead of
the JTAG default.

```tcl
# swd-target.cfg - adapter config for a Cortex-M target over SWD
source [find interface/cmsis-dap.cfg]
transport select swd
adapter speed 1000
source [find target/stm32f1x.cfg]

# Slower is more reliable on long wires or test-point clips
# adapter speed 100
```

```bash
# Confirm the debug port before touching flash or RAM
openocd -f swd-target.cfg \
  -c "init" \
  -c "dap info 0" \
  -c "targets" \
  -c "halt" \
  -c "reg" \
  -c "resume" \
  -c "shutdown" 2>&1 | tee swd-probe.log
```

Read the log for three things: a DP IDCODE, a target listed as
halted after the halt command, and a register dump with a plausible
program counter. If the halt fails but the IDCODE reads fine, the core
may be in a low power state or the reset line may need connecting.

## 4. Dumping memory over SWD

Halt first, dump second, and hash every dump at capture time so a
later corrupted copy is detectable.

```bash
# Halt, dump flash and RAM regions in scope, hash each output
openocd -f swd-target.cfg \
  -c "init" -c "halt" \
  -c "dump_image flash.bin 0x08000000 0x10000" \
  -c "dump_image ram.bin 0x20000000 0x8000" \
  -c "resume" -c "shutdown" 2>&1 | tee swd-dump.log

sha256sum flash.bin ram.bin | tee swd-dump.sha256
ls -l flash.bin ram.bin
```

```python
#!/usr/bin/env python3
"""Check an SWD dump for the obvious failure modes before analysis."""
import sys

path = sys.argv[1]
data = open(path, "rb").read()
if not data:
    sys.exit("dump is empty, the halt or address range was wrong")
if data == b"\x00" * len(data):
    sys.exit("dump is all zeros, the core was not halted or the range is unmapped")
if data == b"\xff" * len(data):
    sys.exit("dump is all 0xff, the range is erased flash or unmapped")
print(f"{path} - {len(data)} bytes, first 16 bytes - {data[:16].hex()}")
```

## Edge cases

- Locked or disabled debug: some chips blow a debug lock fuse or set
  option bytes that disable SWD. The IDCODE may still read while
  memory access is blocked. Treat this as a hard stop for that path
  and document it, rather than forcing the port.
- 1.8 V targets: a 3.3 V adapter on a 1.8 V header can damage the
  target. Measure Vref, set the adapter voltage, and use a level
  shifter when the adapter cannot match.
- SWDIO and SWCLK swapped: the most common first-attempt failure.
  Swap the two signal wires and retry before changing anything else.
- Unstable links on clips and test points: drop the adapter speed to
  100 kHz, shorten the wires, and add a solid ground connection
  before blaming the target.
- Core in sleep or stop mode: halt may fail until the device wakes.
  Trigger a normal wake event, such as a button press or a UART
  command, then halt quickly.
- Shared pins: SWD pins sometimes double as GPIO after boot. Probe
  during reset or early boot, when the debug function is active,
  rather than after the application reconfigures the pins.
- Reset line held low: if the target never boots, check that the
  adapter is not holding reset asserted, and disconnect the reset
  wire unless you explicitly need reset control.

## Key references

- ARM Debug Interface Architecture Specification, SWD protocol and DP
  register descriptions.
- OpenOCD user guide, SWD transport selection and dap commands.
- Chip vendor reference manual for the target family, debug port and
  memory map chapters.
- The parent uart-jtag skill for UART console access and general
  JTAG header identification.

