This guide will compile OpenOCD 0.5.0 for Ubuntu 10.04 with the FTD2XX driver library, for use with the TinCanTools Flyswatter.
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 libtoolsudo apt-get install autoconfsudo apt-get install texinfosudo apt-get install 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.4sudo cp ftd2xx.h /usr/includesudo cp WinTypes.h /usr/includecd /usr/local/includesudo ln -s /usr/include/ftd2xx.h ftd2xx.hsudo 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/i386sudo 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_64sudo 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/libsudo ln -s libftd2xx.so.1.0.4 libftd2xx.socd /usr/libsudo ln -s /usr/local/lib/libftd2xx.so.1.0.4 libftd2xx.so
Download the OpenOCD 0.5.0 source from http://prdownload.berlios.de/openocd/openocd-0.5.0.tar.gz and extract openocd-0.5.0 to your home directory (/home/USERNAME/openocd-0.5.0).
The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and 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.0patch -p1 -i Tincantools-openocd-b0.12.patch
Even if you do not need Flyswatter3 or 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.
In the terminal window, navigate to the new folder containing the OpenOCD source and compile as follows.
cd ~/openocd-0.5.0sudo ./configure --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-linux-tardir="../libftd2xx1.0.4"sudo makesudo 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-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:
cd ~mkdir openocd-bincd ~/openocd-0.5.0/tclcp -r * ~/openocd-bincd ~/openocd-0.5.0/srccp openocd ~/openocd-bin
openocd-bin should now contain the following files and subdirectories: