SWD#

Serial Wire Debug. ARM’s two-wire JTAG replacement on Cortex-M parts; the same debug capability (halt, register read/write, flash program) over a clock line and a bidirectional data line. Smaller header, smaller pin count, same access. When the operator finds an ARM micro on a target and the JTAG pads look stripped, SWD is the next thing to try.

Wires#

Signal

Direction

Purpose

SWCLK

Probe out

Serial Wire clock.

SWDIO

Bidirectional

Serial Wire data; the probe drives it during the request phase, the target drives it during the response phase.

SWO (optional)

Probe in

Serial Wire Output; one-way trace channel from target to probe (ITM and DWT data).

RESET (optional)

Probe out

System reset; same purpose as JTAG’s SRST.

GND

Reference

Ground.

The 10-pin 0.05-inch Cortex Debug connector is the standard SWD/JTAG header on production boards.

Wire format#

Every transaction is a 46-bit packet on SWDIO clocked by SWCLK.

  • Header (8 bits): start, AP/DP select, R/W, address bits, parity, stop, park.

  • ACK (3 bits, target-driven): OK, WAIT, or FAULT.

  • Data (32 bits) plus parity, in the direction set by the header.

A DAP (Debug Access Port) is the chip-level peer of the probe; behind it sits one or more APs (Access Ports), most commonly an MEM-AP that exposes the chip’s memory bus.

Pads#

ARM Cortex Debug pinout (10-pin, 0.05-inch pitch):

Pin

Signal

1

VTref (target voltage reference)

2

SWDIO

3

GND

4

SWCLK

5

GND

6

SWO

7

NC (key)

8

NC

9

GNDDetect

10

nRESET

A 4-pad arrangement (SWDIO, SWCLK, GND, Vcc) is the operator’s most common find on hobby and lower-end commercial boards.

Tools#

Tool

Effect

OpenOCD

Open-source SWD daemon; -c "transport select swd".

ST-Link

SWD adapter built into every STM32 Discovery and Nucleo board; the cheapest fast SWD probe.

BlackMagic Probe

SWD probe with a built-in gdb server; no OpenOCD needed.

J-Link

Commercial probe with the broadest target support.

CMSIS-DAP probes (DAPLink)

ARM’s open-standard probe firmware; runs on many cheap boards.

pyOCD

Python alternative to OpenOCD for CMSIS-DAP probes.

References#