From EdWiki

Revision as of 15:35, 15 March 2022 by Jshankar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This guide will compile OpenOCD {{{3}}} for Ubuntu 10.04 with the {{{{{2}}}_NAME_CAPS}} driver library, for use with the TinCanTools Flyswatter.

Installing Packages

You will need to install several packages to compile and run OpenOCD. Open a terminal window (Applications menu > Accessories > Terminal) and type:

sudo apt-get install libtool autoconf texinfo libusb-dev

If you prefer to compile libusb yourself, you can find the source at

Installing libFTD2XX

Download version {{{{{2}}}_VERNUM}} of the D2XX Linux drivers from Direct link is here:{{{{{2}}}_VERNUM}}.tar.gz. Extract the contents to your home directory (/home/USERNAME, replacing USERNAME with your username.)

In the terminal window, navigate to ~/libftd2xx{{{{{2}}}_VERNUM}} and copy the files ftd2xx.h and WinTypes.h to /usr/local/include. Then navigate to /usr/include and create symbolic links to the header files.

cd ~/libftd2xx{{{{{2}}}_VERNUM}}
sudo cp ftd2xx.h /usr/include
sudo cp WinTypes.h /usr/include
cd /usr/local/include
sudo ln -s /usr/include/ftd2xx.h ftd2xx.h
sudo ln -s /usr/include/WinTypes.h WinTypes.h

Now return to the ~/libftd2xx{{{{{2}}}_VERNUM}} directory and copy the library file to /usr/local/lib. The libftd2xx directory contains both 32-bit and 64-bit library files. If in doubt, use the 32-bit library file. To install the 32-bit library, copy the file located in /build/i386:

cd ~/libftd2xx{{{{{2}}}_VERNUM}}/build/i386
sudo cp{{{2}}} /usr/local/lib

To install the 64-bit libraries, instead copy the file in /build/x86_64:

cd ~/libftd2xx{{{{{2}}}_VERNUM}}/build/i386
sudo cp{{{2}}} /usr/lib

Regardless of which you install, create symbolic links to the file in /usr/lib and /usr/local/lib:

cd /usr/local/lib
sudo ln -s{{{2}}}
cd /usr/lib
sudo ln -s /usr/local/lib/{{{2}}}

Downloading OpenOCD

Download the OpenOCD {{{3}}} source from and extract openocd-{{{3}}} to your home directory (/home/USERNAME/openocd-{{{3}}}). This source doesn't include support for CEDT-SW-JTAG adapter.

Patching OpenOCD

The openocd-0.5.0-with-CEDT-SW-JTAG-support.patch patch provides support for CEDT-SW-JTAG adapter and config file for OpenOCD-0.5.0. Download the file openocd-0.5.0-with-CEDT-SW-JTAG-support.patch and 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 openocd-0.5.0-with-CEDT-SW-JTAG-support.patch

Compiling OpenOCD

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

cd ~/openocd-{{{3}}}
sudo ./configure --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-linux-tardir="../libftd2xx{{{{{2}}}_VERNUM}}"
sudo make
sudo make install

Preparing to Run OpenOCD

Navigate to /home/USERNAME/openocd/src to find the openocd binary. You will need superuser priveleges to run OpenOCD.

You can run openocd from /home/USERNAME/openocd-{{{3}}}/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 following commands:

cd ~
mkdir openocd-bin
cd ~/openocd/tcl
cp -r * ~/openocd-bin
cd ~/openocd/src
cp openocd ~/openocd-bin

openocd-bin should now contain the following files and subdirectories:


You can now run OpenOCD from /home/USERNAME/openocd-bin. To get started running OpenOCD, see Running OpenOCD on Linux.