Compiling OpenOCD takes about 15 minutes but is worth the effort to get the latest code. You'll  need to have command line access and a Pi on the Internet so you can download packages and software.

Thanks to https://petervanhoyweghen.wordpress.com/2015/10/11/burning-zero-bootloader-with-beaglebone-as-swd-programmer/ for the great tutorial, we're just adapting it for Pi usage!

Compiling OpenOCD

Start by doing a fresh sudo apt-get update this will make sure you have the latest packages and repository set up.

Next, run

sudo apt-get install git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev

to install all the tools you'll need to compile OpenOCD. OpenOCD changes a lot and is under constant development so we do suggest compiling your own!

Download the latest source code for OpenOCD with

git clone http://openocd.zylin.com/openocd

Change into the code directory and run the bootstrapper with:

cd openocd-code
./bootstrap

Next, we will compile OpenOCD with the Raspberry Pi native GPIO twiddling support - this will work on various Raspberry Pi's despite being called 'bcm2835gpio'

./configure --enable-sysfsgpio --enable-bcm2835gpio

If you're following this guide on a non-Pi embedded linux board, you can skip the --enable-bcm2835gpio part and try to just use sysfsgpio. Sysfsgpio is much slower than native GPIO twiddling but it may not matter too much in your application.

Note that when done, it wont mention GPIO support in the configuration summary, thats OK!

Run make

Assuming compilation completes successfully as above, you can install with

sudo make install

That's pretty much it!

You can see the list of interfaces available in /usr/local/share/openocd/scripts/interface

There's a lot of options, in particular check out raspberrypi2-native.cfg and raspberrypi-native.cfg if you are interested in using OpenOCD with a non-Pi, look at sysfsgpio-raspberrypi.cfg which can help you port to a different linux computer

This guide was first published on Mar 16, 2016. It was last updated on Mar 08, 2024.

This page (Compiling OpenOCD) was last updated on Mar 08, 2024.

Text editor powered by tinymce.