Leash Debugger: a WiFi-enabled JTAG debug adapter
If you spend a lot of time developing firmware, you’ve probably had to work with a multitude of IDE’s, compilers, debuggers and JTAG/SWD debug adapters. If so, then you’ve probably also had your share of issues in setting up the debugging tools to work properly with your particular combination of OS, debugger, debug adapter and target. Setting up a GDB-based debugging workflow is no exception.
Unfortunately, using GDB to debug firmware is rarely a “plug-and-play” experience. You need a middleware layer like OpenOCD which GDB can talk to, an adapter which OpenOCD can talk to, and a target which the debug adapter can talk to – and it all needs to work magically together. Ever heard of a game called “telephone“?
And for the record, it often does work magically together. OpenOCD is an amazing piece of software. It supports an incredible range of platforms, target chips/simulators and debug adapters, and is architected in such a way that adding support for new devices can often be as simple as writing a small TCL script or modifying an existing one.
But now and then, the magic refuses to happen easily. Ironically, I experienced this for the very project this blog post is about – I took an entire day to get my OpenOCD-based debugging setup working. This time was mostly spent on battling different FTDI USB drivers and modifying the OpenOCD scripts, which had not been meant to use with these drivers.
Admittedly, the time that took was mostly due to my own lack of prior knowledge. But when you are in a rush to develop a feature, or want to bring a colleague into a project quickly and hit the ground running, it can be frustrating to have to go through these steps.
To help speed up our prototyping efforts, here at Mindtribe we’ve developed an alternative: Leash Debugger. It’s JTAG debug adapter firmware which doesn’t require middleware like OpenOCD to connect to GDB for a debugging session – instead, it connects directly to GDB over WiFi. This brings extra advantages along with it:
- No cables required.
- The debug adapter and target may be anywhere in the world, as long as a network connection can be made to it.
- The host workstation can easily switch between multiple debug adapters and targets, by just connecting to a different IP address. An application for this could be to do batch flash-programming of multiple targets.
- If you’re in a nefarious mood, you can connect to your colleague’s debug adapter on the other side of the room before he/she does, and freak him/her out by flashing LEDs randomly.
Leash Debugger is open-source and runs on the Texas Instruments CC3200. You could run it on any CC3200 board that has access to at least 4 exposed GPIO pins – including the Launchpad boards from TI. We are also working on support for this nifty little WiFi board from Read Bear Labs. This one is especially convenient since it snaps right onto the target!
To see whether this really makes a difference in the setup time associated with working with the CC3200, I gave Jim two CC3200 Launchpad boards and access to Leash Debugger’s quick-start guide on GitHub. He had a debugging session going within 30 minutes, putting my own setup time for this dev board to shame.
There are several other nifty features:
- With Leash Debugger you can program files onto the target’s serial flash right from the GDB command-line, over WiFi. Flashing funtionality is normally only offered by TI’s proprietary tools.
- By using a subset of ARM’s Semihosting Protocol, the program being debugged can request the user to input data on the GDB command-line, or output printf-style information to the GDB console.
For now, Leash Debugger only supports the TI CC3200 MCU as a debug target, using a 4-wire JTAG interface. We might be adding support for other MCU’s and interfaces (eg SWD) in the future. In the meantime, if you happen to have any two CC3200-based boards lying around, some jumper cables and some spare time, be sure to give this debugger a try.
This was an awesome internship project to be working on at Mindtribe – I hope it makes some people’s lives slightly easier!