Home / Learn Chip Programming / SWD and JTAG: Hardware Debug Interfaces

SWD and JTAG: Hardware Debug Interfaces

Two or four wires give you breakpoints, memory access and flashing.

In shortTwo or four wires give you breakpoints, memory access and flashing.

Theory in plain words

Debug connectionPC: GDB / IDEUSBprobe: ST-LINK / J-Link / CMSIS-DAPSWDIO + SWCLK + GNDtarget MCU core
Debug connection

What it is

SWD (Serial Wire Debug) uses SWDIO and SWCLK; JTAG uses TCK, TMS, TDI, TDO (+TRST). ARM debug logic (CoreSight) lets a probe halt the CPU, read/write memory, set breakpoints and flash.

Why we use it

No professional firmware work happens without a hardware debugger: ST-LINK, J-Link, CMSIS-DAP, Black Magic Probe.

How it works

Connect SWDIO, SWCLK, GND, and (optionally) NRST and SWO to the probe. Use OpenOCD or vendor IDE to connect. 10-pin 1.27 mm Cortex Debug connector is standard.

Where it is used

  • Flashing and debugging STM32/nRF/RP2040
  • Production programming
  • Reading a stuck system

Pin mapper

Wire the debug connectorTry it Yourself

SWD only needs two signal wires: that is why ARM MCUs use it.

ProbePrice (India)Strength
ST-LINK V2 cloneRs 300 to 500STM32 only, cheap
Nucleo on-board ST-LINKincludedSTM32 and others via SWD pins
Raspberry Pi Pico as debugprobeRs 350CMSIS-DAP, any ARM Cortex-M
SEGGER J-Link EDU MiniRs 4000+fast, any ARM, RTT
Black Magic ProbeRs 5000built-in GDB server, no OpenOCD
ESP-PROG / ESP32-S3 USB-JTAGRs 700 / built-inESP32 JTAG
Tip:Turn a Raspberry Pi Pico into a debugger by flashing the debugprobe firmware: wire GP2 to SWCLK, GP3 to SWDIO and share ground.

Quick quiz

1. Minimum wires for SWD?

2. Which probe is built into Nucleo boards?

Common questions

Minimum wires for SWD?

SWDIO, SWCLK and GND. Plus VTref helps for level matching.

Which probe is built into Nucleo boards?

ST-LINK. Usable for other targets too.