Using JTAG and Eclipse on MacOS

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:JTAG box end

Pin allocation

Segger setup

Breadboard connection

(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:

STM32F100 segger

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 first trying the explicit device command like this (for example):

JLink> device stm32f100c8

and then specifying explicitly to use SWD like this:

JLink> si 1

You can type a question mark on the JLink command line to get a list of all possible embedded commands.

(3) Set up GDB within Eclipse

Last step is to make Eclipse aware of the Segger box. The totally excellent “MCU on Eclipse” blog by Erich Styger shows in detail here how to set up Eclipse, GDB and Debug Configurations, so I am not going to duplicate it. What I do show instead is what you need to do differently for a Mac OS + Segger implementation.

With your Eclipse project selected, click the down arrow of the bug icon on the main Eclipse screen:

 Screen Shot 2014-08-08 at 11.42.01 PM

and select Debug Configurations. Create a new debug configuration for your project.

Then just copy the settings from the next 2 screen dumps. The key one to get right is the “Executable” link to the location of JLinkGDBServer:

Screen Shot 2014-08-08 at 11.40.47 PM

Screen Shot 2014-08-08 at 11.41.24 PM

Leave a Reply

Your email address will not be published. Required fields are marked *