OpenOCD Support? (Using the Raspberry Pi as a JTAG Interface!)

Has anyone gotten the Spark Core working with OpenOCD? I know it supports the STM32, so I should be able to get it working, I just wanted to see if someone already has a definition.

In the latest release there’s support for bit-banging a JTAG interface over GPIO on the Raspberry Pi. So I think I can get a nice little JTAG programmer/debugger working for those of you with a Pi!


That would be wonderful! The creativity and ingenuity in this forum is amazing.

1 Like

Haha, thanks! :smiley:

I’ll put this on the top of my list for today. I’ll keep detailed instructions and most likely post the entire .img file once I get it working, so you can just load it onto an SD card and wire the Core up. Most likely I’ll end up making a shield out of some perfboard (or maybe this Adafruit Proto-Shield I’ve had sitting around for ages), but it shouldn’t be hard to breadboard.

(I’ll be putting a Logic header directly on the board, plus LEDs for testing. I think I’ll route the Core’s I2C, UART and SPI ports directly to the Pi’s for easy two-way testing of those interfaces. There’s some pretty powerful I2C/SMbus tools for Linux that are amazing for debugging. One of the best is the ability to see the status of every register on an I2C device!)


I have the breadboard version of that. I bought a cheap one from eBay, though, so the breadboard was already glued on top. My poor Arduinos have been collecting dust since I backed this Kickstarter project (my previous project was an nRF24L01 network for cheap wireless).

I’ve gotten the JTAG working using OpenOCD and the ARM-USB-OCD jtag dongle connected to the JTAG shield.

When launching OpenOCD, use this command (If you have a different jtag adapter, update accordingly):

openocd-0.7.0 -f interface/olimex-arm-usb-ocd.cfg -f target/stm32f1x.cfg

Then when launching GDB, start with this startup script like so:

arm-none-eabi-gdb -x jtag.gdb


target remote localhost:3333
file core-firmware.elf

The first thing the core-firmware image does is disable the JTAG pins, so be sure to either halt the chip in reset with your debugger or flash a new image in that doesn’t disable your debug interface first. Also be sure in the image your trying to debug that you disable the JTAG pins remapping… there’s a #define for it.

A note on feedback for the JTAG shield… its Ok but basically impossible to use with an external circuit or breadboard. So its fine if your doing pure software… like porting a RTOS, but for debugging with external hardware there’s no easy way to connect it.

If the spark socket was rotated 90 degrees and the board itself was made only as thin as required to support the 700 mils for the socket I could solder in headers and pogo the shield onto a breadboard.

This is why I made one like this:

I agree with your idea but in the mean time could you just desolder the headers and install stackable headers? ( you really need 12 pins, but they should work … if you can find them at digikey let me know! )

Would be dead simple to make a pcb, and share the OSHpark order link…

1 Like

There is an extra row of plated through holes already on the JTAG shield I imagine was intended for soldering in a 2nd set of headers on the bottom for pogo into a protoboard, the problem is that the vertical overall orientation of the shield blocks your access to the pins in the protoboard below.

I really like your vertical jtag plug in board, If I get a free evening I may design the two boards an upload to OSHPark if anyone else is interested. Does anyone know offhand the part number (mouser) for the 20 pin jtag shrouded header?

I was thinking that starting with the Spark Programmer Shield would be the easiest thing to do.

Their BOM is loaded with over seas venders though, so here’s some stuff at digikey:

Cheapest 20 pin dual row shrouded vertical male 0.1" male header: ($0.44 ea.)

Cheapest 10k 1% 1/4W through hole resistors: ($0.10 ea. x 4)

Gold plated (for easy breadboard insertion) 12-pin 0.1" male header: ($0.48 ea x 2)

PCB (1.2" x 2.0" thereabouts) 2.4sq. in x $5/sqin. = $12 for 3 boards. ($4 ea.)

$6 Total!

Vertical board would be even cheaper… you’d probably want a
Tin plated (less pins less force) 9-pin 0.1" male rt/angle header: ($0.81 ea)

Vertical PCB would be a little smaller so less cost.

You’ll be done in about 10 minutes I think!

I want one of these when you order 3 :smile: $10 for the whole kit shipped?

I started working on my own little JTAG shield today. Right now it’s got a normal 20 pin JTAG connector, a 26 pin Raspberry Pi connector, a socket for the Spark Core and space for a half-size breadboard. I’ve got female headers routed on both sides of the breadboard which bring out all the Spark Core signals, with an additional row of male headers nearby for signal probing use (Logic, Scope, Bus Pirate, DMM).

The entire BOM is available on Digikey for about $7. I’ll post a link to the board here soon if anyone wants to take a look!

1 Like

Okay, I got the Pi talking to the Spark Core via OpenOCD! I still need to do a bit more testing here, but it looks like this is going to work perfectly. :smiley:


@timb - I am all over this board if you ever make it as a kit.

Thanks to @mattande’s instructions I managed to debug my spark core! I used the Olimex arm-usb-ocd-h JTAG dongle and the JTAG shield.

Here are some more hints:
OpenOCD 0.8.0 has deprecated support for the ft2232 interface, so I needed to use the following command:

openocd -f interface/ftdi/olimex-arm-usb-ocd-h.cfg -f target/stm32f1x.cfg

Note the interface file comes from the ftdi directory.

I built (and flashed) my firmware with the following command to set the #defines such that the JTAG pins were enabled and to build with debug symbols (I’d expect DEBUG_BUILD to do that, anyway! :slight_smile: ):

DEBUG_BUILD=y USE_SWD_JTAG=y make [program-dfu]

@timb Do you have a breadboard diagram? Looking to do this with my Raspberry Pi :smile:

Hi Timb

Have u completed the JTAG programmer/debugger using raspberry PI?
If yes, please do share some information on it. I am also interested in the same