Convert Your Raspberry Pi Into a Networked JTAG Debugger
Introducing the $27 JTAG HAT!
Having a hardware debugging tool on hand can prove useful, especially when developing embedded products. Low-level debugging can be performed at home with a JTAG debugger and OpenOCD, but at-home setups often lack a JTAG debugger. Tools like the Black Magic probe can also work well but lack the flexibility of a Raspberry Pi with OpenOCD. This is a cheap and convenient solution for messing around with a variety of microcontrollers and embedded devices. However, finding the cables to connect the RPi to your board can turn into a project in itself. Matt Mets of BlinkinLabs decided to cut out the headache of converting the 0.1” headers on a Raspberry Pi to the 1.27mm pins on a board. His JTAG HAT design includes properly-labeled 20-pin 0.1” and 1.27mm Cortex Debug Connectors, making the process streamlined instead of a hassle.
The JTAG HAT is designed to work with OpenOCD, which supports debugging a large number of devices, such as the STM32 and ESP32. On-board level shifters allow you to connect to targets with JTAG and SWD interfaces from 1.8V to 5V. Target power is selectable when the device is powered from the RPi 3.3V supply. The header includes a level-shifted UART interface connected to the RPi serial port, built-in voltage and current measurement of the target device, and the ability to perform a hardware reset, both SRST and TRST, via a pull-down transistor. The open hardware board also contains a labeled 0.1” pin, perfect for jumper wires for more flexibility, as well as a dedicated 10-pin Cortex Debug Connector.
The device can be purchased on Tindie for $27, with the populated and tested JTAG HAT PCB and the nylon standoffs and screws needed to attach it to an RPi included. The design files and setup instructions are available via GitHub. The instructions provide full documentation for getting the software side up and running, beginning with the initial setup of the Raspberry Pi and a blank SD card through to the installation and configuration of a patched version of OpenOCD specifically for the JTAG HAT. Whether you buy one or undertake building your own, having one around could be especially handy if you spend a lot of time working with the appropriate chips