Though many eval boards come with an embedded JTAG-USB interface, I still like to use a separate purpose-built JTAG debug box.
If you pick the right one:
- It can be used with many boards and SoCs. Once set up, one debug toolchain works for many projects.
- You can use it to debug MCUs on bread-boarded projects. You will need to make a hacked SWD cable like the one I show in this post.
- Not that expensive. I picked up a Segger JTAG EDU on a home-use deal for $60. I remember the early days at ARM when we first launched our “EmbeddedICE” box; the price then was over $1K….Today you can get some very cheap $20 knock offs from China on EBay and AliExpress. These may or may not work, but I believe it not worth my time to rely on dodgy tools with questionable software.
- It works natively with Mac OSX. At least the Segger version does. I don’t need to run Fusion, Parallels or Virtual Box.
- Does not require special USB drivers etc. The Mac version works by looking like a TCP device and speaking IP.
- Supported directly under Eclipse. Again no special driver required
- Supports SWD or full JTAG
(1) Connection to the target
The first thing you will need is a SWD cable. I made one out of some 20 core ribbon cable and a 20 pin IDC box connector. The ARM documentation on SWD pinouts is highly ambiguous since they talk about the pins to a “connector”. What’s a connector? Do they mean the plug (male) or socket (female)? I figured out the Segger pin out by using a Salaea Logic Analyzer:
(2) Get the Segger software tools working
On a Mac, this is as simple as starting the JLinkExe terminal application in the Segger Application folder. Don’t try and use the JLinkGDBServer app from terminal.
If all is well, JLinkExe reports something like this:
Note how JLinkExe switched automatically to SWD. This works most of the time, but not always. It depends on whether your target device is “known” to the box or not. If it is not known, you can fix this by