Compiling OpenOCD Linux

This guide will compile OpenOCD 0.5.0 for Ubuntu 10.04 with the LibFTDI driver library, for use with the TinCanTools Flyswatter. This is the most recent release version of OpenOCD. It does not include support for the Flyswatter2, but this guide includes instructions on adding Flyswatter2 support with a patch. OpenOCD 0.6.0 (currently in development) does include support for the Flyswatter2, but is subject to change at any time and may be more difficult to compile. If you would prefer to use the most recent version of the source currently in development rather than the 0.5.0 release, see Compiling OpenOCD v06 Linux.

Downloading and Compiling libFTDI

libFTDI is an open source library that enables you to talk to FTDI chips like: FT232BM, FT245BM, FT245R, FT2232C, FT2232D and FT2232H. You will need libFTDI to compile OpenOCD. Download libftdi-0.19.tar.gz from:
http://www.intra2net.com/en/developer/libftdi/download.php
and extract it to your home directory (/home/USERNAME, replacing USERNAME with your username).

Navigate to home/USERNAME/libftdi-0.19/src, and copy ftdi.hto your /usr/include directory. Then create a symbolic link to ftdi.h in /usr/local/include. In the terminal window:

Downloading OpenOCD

Patching OpenOCD

The OpenOCD Flyswatter2 beta patch provides support for the Flyswatter2 and updated config files for the original Flyswatter, the TinCanTools Hammer, and the Olimex PIC-P32MX board. Download the file Media:Tincantools-openocd-b0.12.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.5.0 directory.

In the terminal window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.5.0
patch -p1 -i Tincantools-openocd-b0.12.patch

Even if you do not need Flyswatter2 support, you will need the updated config files in this patch to use the Flyswatter with OpenOCD-0.5.0. If you do not wish to install the patch you can download the config files individually from OpenOCD Config Files.

Compiling OpenOCD

In the terminal window, navigate to the new folder containing the OpenOCD source and compile as follows.

Navigate to /home/USERNAME/openocd-0.5.0/src to find the openocd binary. You will need superuser privileges (the sudo command) to run OpenOCD.

Preparing to Run OpenOCD

You can run openocd from /home/USERNAME/openocd-0.5.0/src, but you may encounter problems with configuration files. For a more in-depth discussion of these issues, see OpenOCD Config File Paths. This guide recommends that you create a new directory containing OpenOCD and its config files.

Create a new directory in /home/USERNAME called openocd-bin, and copy the openocd binary and the contents of /home/USERNAME/openocd/tcl to the new directory. You can do this from the terminal window with the collowing commands: