CompileOpenOCDLinux
From EdWiki
This guide will compile OpenOCD {{{3}}} for Ubuntu 10.04 OR Later version with the {{{{{2}}}_NAME_CAPS}} driver library, for use with the CEDT USB Adapter.
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 http://sourceforge.net/projects/libusb/files/libusb-1.0/.
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-{{{{{2}}}_VERNUM}}.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-{{{{{2}}}_VERNUM}}/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-{{{{{2}}}_VERNUM}}/src sudo cp ftdi.h /usr/include cd /usr/local/include sudo ln -s /usr/include/ftdi.h ftdi.h
Return to your libftdi-{{{{{2}}}_VERNUM}} directory and compile.
cd ~/libftdi-{{{{{2}}}_VERNUM}} ./configure make 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/libftdi.la libftdi.la sudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1.19.0 sudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so sudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1
Downloading OpenOCD
Download the OpenOCD {{{3}}} source from http://prdownload.berlios.de/openocd/openocd-{{{3}}}.tar.gz and extract it to /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_libftdi 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 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
You can now run OpenOCD from /home/USERNAME/openocd-bin. To get started running OpenOCD, see Running OpenOCD on Linux.