This guide will compile OpenOCD 0.6.0 for Ubuntu 10.04 with the FTD2XX driver library, for use with the TinCanTools Flyswatter, Flyswatter2, and Flyswatter3. Version 0.6.0 is the version of OpenOCD currently in development. For instructions on compiling with the most recent release code, see Compiling OpenOCD Linux.
OpenOCD 0.6.0 vs the 0.5.0 Release
This guide uses the most recent version of the OpenOCD source currently in development. Unlike the 0.5.0 release the development version includes support for the Flyswatter2 and Flyswatter3, so you won't need to download or apply a patch before compiling. However, the development code is subject to change at any time. If you encounter problems with this option, try the OpenOCD 0.5.0 instructions in Compiling OpenOCD Linux D2XX instead.
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 http://sourceforge.net/projects/libusb/files/libusb-1.0/.
Download version 1.0.4 of the D2XX Linux drivers from http://www.ftdichip.com. Direct link is here: http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx1.0.4.tar.gz. Extract the contents to your home directory (/home/USERNAME, replacing USERNAME with your username.)
In the terminal window, navigate to ~/libftd2xx1.0.4 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 ~/libftd2xx1.0.4 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 ~/libftd2xx1.0.4 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 ~/libftd2xx1.0.4/build/i386 sudo cp libftd2xx.so.1.0.4 /usr/local/lib
To install the 64-bit libraries, instead copy the file in /build/x86_64:
cd ~/libftd2xx/build/x86_64 sudo cp libftd2xx.so.1.0.4 /usr/local/lib
Regardless of which you install, create symbolic links to the file in /usr/lib and /usr/local/lib. Name the links libftd2xx.so.
cd /usr/local/lib sudo ln -s libftd2xx.so.1.0.4 libftd2xx.so cd /usr/lib sudo ln -s /usr/local/lib/libftd2xx.so.1.0.4 libftd2xx.so
Git is version control software distributed with Ubuntu. You can use git to download the current development code from the OpenOCD git repository at sourceforge.net. In the terminal window, navigate to your home directory and make sure you don't already have a directory there named openocd/. (Downloading with git will create a directory called openocd/ containing the OpenOCD source. 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 ~ git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
There should now be a folder in your home directory called openocd/.
In the terminal window, navigate to the new folder containing the OpenOCD source and compile as follows.
cd ~/openocd sudo ./bootstrap sudo ./configure --enable-maintainer-mode --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-linux-tardir="../libftd2xx1.0.4" sudo make sudo make install
Navigate to /home/USERNAME/openocd/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/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:
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:
board chip cpld cpu openocd interface target test bitsbytes.tcl mem_helper.tcl memory.tcl mmr_helpers.tcl