Compiling OpenOCD v0.6 Linux

From EdWiki

This guide will compile OpenOCD 0.6.0 for Ubuntu 10.04 and higher with the LibFTDI driver library, for use with the STM32L-Discovery Boards. Version 0.6.0 is the version of OpenOCD currently relesed.

OpenOCD 0.6.0 vs the 0.5.0 Release

This guide uses the most recent version of the OpenOCD source. Unlike the 0.5.0 release the 0.6.x version includes support for the STMicroelectronics ST-LINK/V2.

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

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: 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.h to your /usr/include directory. Then create a symbolic link to ftdi.h in /usr/local/include. In the terminal window:

cd ~/libftdi-0.19/src
sudo cp ftdi.h /usr/include
cd /usr/local/include
sudo ln -s /usr/include/ftdi.h ftdi.h

Return to your libftdi-0.19 directory and compile.

cd ~/libftdi-0.19
sudo make install

This will install the necessary library files to /usr/local/lib. Navigate to /usr/lib and create symbolic links to the new files.

cd /usr/lib
sudo ln -s /usr/local/lib/libftdi.a libftdi.a
sudo ln -s /usr/local/lib/
sudo ln -s /usr/local/lib/
sudo ln -s /usr/local/lib/
sudo ln -s /usr/local/lib/

Downloading OpenOCD

In the terminal window, navigate to your home directory and make sure you don't already have a directory there named openocd/. If you already have a directory called openocd/ either rename it or navigate to a different directory before you proceed.) Then download OpenOCD with the following command:

cd ~
Download the OpenOCD 0.6.0 source from 

and extract it to /home/USERNAME/openocd-0.6.0.

Compiling OpenOCD

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

cd ~/openocd-0.6.0
./configure --enable-maintainer-mode --disable-werror --enable-ft2232_libftdi --enable-stlink

Navigate to /home/USERNAME/openocd-0.6.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.6.0-dev/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-0.6.0-bin and its config files.

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

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

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


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