Debug Probes and Protocols
There are several debugger protocols for embedded systems that permit programs and physical tools (both called debuggers, generically, though properly the tool is a “debug probe”) to attach to a running core to control and inspect its execution.
The most commonly-used function of debuggers and debug probes is flashing (i.e. “writing a program to flash”).
JTAG
JTAG (Joint Test Action Group) is a set of testing specifications, including protocols and connectors for testing circuit boards, ICs, and devices. Colloquially, in the context of MCU/MPU debugging, it refers to the connector and debug protocol: “connect it to a JTAG port”, “I debugged that with a JTAG probe”.
In this context, JTAG is a serial protocol with a clock and data line, though it may include additional pins, such as reset and a second data line for full-duplex communication1.
SWD, SWO
Serial Wire Debug (SWD) is a minimum-two-pin (clock, data) open debug probe interface specified by Arm and largely backwards-compatible with JTAG. Most Arm cores support SWD.
SWD has direct access to in-core buses, and talks to debugger cells designed by Arm.
Serial Wire Output (SWO) is an additional optional data line extension for SWD, allowing serial output from the CPU.
Tooling
- EDBG is an open-source tool for interfacing with a CMSIS-DAP debugger such as Atmel ICE or free-DAP.
- picoprobe is firmware for the RP2040 to make it act as a CMSIS-DAP debug probe.
- JLink OB (On-Board) is firmware for many microcontrollers to make them act as on-board debug probes for other microcontrollers, usually used in devkits
- Can be found in the “firmwares” directory of the J-Link Software Pack
- ESP32s implement JTAG over USB-serial, permitting them to be debugged and flash without additional tooling
UPDI
The protocol used for flashing the new AVR 0,1 and 2-series. It’s extremely simple as it requires only 1 communication wire (+common ground), and is simply based on UART, as long as your serial adapter supports 2 stop bits and even parity bits.
The debug mode of an AVR is initialized by driving its UPDI pin to LOW for an abnormally long duration (=break condition). For this reason, the UPDI pin should always be configured as an input. If it’s not the case, a special high-voltage (12V) re-programming can be performed with the adequate equipment.
pymcuprog can be used to flash a new AVR using a simple serial adapter.