GlossarySWD
SWD
SWD, short for Serial Wire Debug, is a two-wire debug and programming port used on many microcontrollers, defined in the Arm Debug Interface architecture specification. It carries the same debug functions as JTAG on processors that support it, with fewer pins.
How it works
SWD uses SWDIO, a bidirectional data line, and SWCLK, a clock. Reset is usually brought out too, and an optional SWO pin carries trace output. A debug probe connects to these pins and gives a host computer access to the processor's debug port: halting the core, reading and writing memory, setting breakpoints and programming flash.
Many microcontrollers share pins between JTAG and SWD and switch between them with a defined sequence. SWD is the common choice on small microcontrollers because it saves pins, which matters on low pin count packages.
SWD vs JTAG
JTAG uses four or five signals, supports chaining several devices on one port and supports boundary scan testing under IEEE 1149.1. SWD uses two signals and connects to one device's debug port at a time, with no boundary scan. For programming and debugging a single microcontroller, SWD is simpler. For testing board connections or reaching several chips through one header, JTAG is the tool.
Why it matters
SWD is the main programming and debug path on many motor controllers, sensor hubs and peripheral microcontrollers. Without access to it, a board cannot be flashed in production or debugged in the lab. Because it uses so few pins, it is easy to bring out, and easy to forget.
How to get it right
- Bring SWDIO, SWCLK, reset, power and ground to pads or a small connector.
- Use the same pad pattern on every board so one fixture design fits them all.
- Keep the lines short and avoid heavy loads on them.
- Decide whether to lock the debug port on production units, and test that the lock works.
SWD in robotics and drone hardware
A robot or drone often has several microcontrollers, one per motor controller, sensor module or power board. A standard SWD pad pattern on every board lets one programming fixture and script handle all of them.
SWD pads are usually placed as test points so a pogo pin fixture can reach them for firmware flashing at end-of-line test.