What is JTAG and SWD?
Short answer: Both are hardware debug interfaces that let a debug probe halt the CPU, set breakpoints, read and write memory and registers, and program flash. JTAG (IEEE 1149.1) uses 4 or 5 pins (TCK, TMS, TDI, TDO, optional nTRST), supports chaining several chips on one interface, and also provides boundary scan for testing board connections. SWD (Serial Wire Debug) is Arm's 2-pin alternative (SWDIO, SWCLK) with the same debug access to Cortex cores, which is why it is standard on Cortex-M boards.
| JTAG | SWD | |
|---|---|---|
| Pins | TCK, TMS, TDI, TDO (+ nTRST) | SWDIO, SWCLK (+ optional SWO) |
| Multiple devices | daisy chain | one target per interface (multi-drop SWD exists in SWD v2) |
| Boundary scan | yes | no |
| Arm Cortex debug access | yes | yes (same CoreSight debug port) |
| Typical use | FPGAs, CPLDs, Cortex-A SoCs, board test | Cortex-M microcontrollers |
Related signals and features
- SWO (Serial Wire Output): a one-pin trace output for ITM (
printf-style logging viaITM_SendChar, very fast and non-intrusive), data watchpoint trace and PC sampling for profiling. - ETM/ETB/ETR (Embedded Trace Macrocell): full instruction trace, captured by expensive probes or on-chip buffers.
- RTT (SEGGER Real-Time Transfer): uses the debug port to read a ring buffer in RAM, giving fast logging without extra pins.
- nRESET is usually wired to the debug connector so the probe can reset the target ("connect under reset" to recover a chip whose firmware disables SWD pins or goes into deep sleep immediately).
Probes and tools: ST-LINK, SEGGER J-Link, CMSIS-DAP (DAPLink, Raspberry Pi Debug Probe), Lauterbach TRACE32; software such as OpenOCD, pyOCD, GDB, and IDEs (STM32CubeIDE, Keil, IAR, VS Code + Cortex-Debug).
Security: production devices should disable or lock the debug port (read-out protection levels, debug authentication, TrustZone debug restrictions), otherwise anyone with a probe can read the firmware and secrets. Locking is usually irreversible or erases the chip.