Compiling OpenOCD Linux

This guide will compile OpenOCD 0.5.0 for Ubuntu 10.04 with the LibFTDI driver library, for use with the TinCanTools Flyswatter. This is the most recent release version of OpenOCD. It does not include support for the Flyswatter2 or Flyswatter3, but this guide includes instructions on adding Flyswatter2/Flyswatter3 support with a patch. OpenOCD 0.6.0 (currently in development) does include support for the Flyswatter2 and Flyswatter3, but is subject to change at any time and may be more difficult to compile. If you would prefer to use the most recent version of the source currently in development rather than the 0.5.0 release, see Compiling OpenOCD v06 Linux.

 

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-0.19.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-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/srcsudo cp ftdi.h /usr/includecd /usr/local/includesudo ln -s /usr/include/ftdi.h ftdi.h

Return to your libftdi-0.19 directory and compile.

cd ~/libftdi-0.19./configuremakesudo 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/libsudo ln -s /usr/local/lib/libftdi.a libftdi.asudo ln -s /usr/local/lib/libftdi.la libftdi.lasudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1.19.0sudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.sosudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1

 

Downloading OpenOCD

Download the OpenOCD 0.5.0 source from http://prdownload.berlios.de/openocd/openocd-0.5.0.tar.gz and extract it to /home/USERNAME/openocd-0.5.0.

 

Patching OpenOCD

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.

 

Compiling OpenOCD

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_libftdisudo makesudo make install

Navigate to /home/USERNAME/openocd-0.5.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.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/tclcp -r * ~/openocd-bincd ~/openocd/srccp openocd ~/openocd-bin

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

boardchipcpldcpuopenocdinterfacetargettestbitsbytes.tclmem_helper.tclmemory.tclmmr_helpers.tcl

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

Compiling OpenOCD v04 Linux

This guide will compile OpenOCD 0.4.0 for Ubuntu 10.04 with the LibFTDI driver library, for use with the TinCanTools Flyswatter. This is the most recent release version of OpenOCD. It does not include support for the Flyswatter2 or Flyswatter3, but this guide includes instructions on adding Flyswatter2/Flyswatter3 support with a patch. OpenOCD 0.6.0 (currently in development) does include support for the Flyswatter2 and Flyswatter3, but is subject to change at any time and may be more difficult to compile. If you would prefer to use the most recent version of the source currently in development rather than the 0.5.0 release, see Compiling OpenOCD v06 Linux.

 

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-0.19.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-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/srcsudo cp ftdi.h /usr/includecd /usr/local/includesudo ln -s /usr/include/ftdi.h ftdi.h

Return to your libftdi-0.19 directory and compile.

cd ~/libftdi-0.19./configuremakesudo 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/libsudo ln -s /usr/local/lib/libftdi.a libftdi.asudo ln -s /usr/local/lib/libftdi.la libftdi.lasudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1.19.0sudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.sosudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1

 

Downloading OpenOCD

Download the OpenOCD 0.4.0 source from http://prdownload.berlios.de/openocd/openocd-0.4.0.tar.gz and extract it to /home/USERNAME/openocd-0.4.0.

 

Installing the Flyswatter 2 / Flyswatter 3 Patch (Optional)

The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and Flyswatter2, a config file for the Olimex PIC-P32MX development board, and an updated config file for the TinCanTools Hammer. Download the file Media:Openocd-fs3-b0.1.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.4.0 directory.

In the terminal window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.4.0patch -p1 -i Openocd-fs3-b0.1.patch

For more information on the config files added by this patch, see OpenOCD Config Files.

 

Compiling OpenOCD

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

cd ~/openocd-0.4.0sudo ./configure --disable-werror --enable-ft2232_libftdisudo makesudo make install

Navigate to /home/USERNAME/openocd-0.5.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.4.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/tclcp -r * ~/openocd-bincd ~/openocd/srccp openocd ~/openocd-bin

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

boardchipcpldcpuopenocdinterfacetargettestbitsbytes.tclmem_helper.tclmemory.tclmmr_helpers.tcl

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

Compiling OpenOCD WinXP D2XX

This guide will compile OpenOCD 0.5.0 on Windows XP with the FTD2XX driver library, for use with the TinCanTools Flyswatter. The executable created with this guide is compatible with Windows XP and Windows 7. The process is identical on 32 and 64 bit versions of Windows.

This guide makes use of the GCC cross-compiler added to Cygwin on June 2, 2011. The cross-compiler makes compiling OpenOCD for Windows much easier. Older instructions can be found at Compiling OpenOCD for Windows XP (FTD2XX) – Pre June 2011.

 

 

Installing Cygwin

Download and install Cygwin 1.7.9 from http://www.cygwin.com. Cygwin provides a GNU development environment for Windows, which will allow you to compile OpenOCD using the GNU Compiler Collection (GCC). You will not need Cygwin to run OpenOCD. The Cygwin installer is available at http://cygwin.com/install.html.

Installing Cygwin Packages

If you already have Cygwin installed, this guide recommends that you delete it and reinstall completely. Close all Cygwin windows and services and delete your Cygwin directory (by default, C:\cygwin). Then find any packages downloaded but not installed and delete them as well. You set the location of these files when you installed Cygwin. By default they appear in My Documents/Downloads. If you don’t wish to reinstall Cygwin you can find more information at http://cygwin.com/ml/cygwin/2011-06/msg00021.html.

In the Cygwin installer you will be prompted to select additional packages to install. Install the following optional packages, found under the Devel heading:

 

  • autoconf (all packages)
  • automake (all packages)
  • binutils
  • gcc
  • gcc-core
  • gcc-g++
  • git
  • libtool
  • libusb-1.0
  • libusb-win32
  • libusb-devel
  • make
  • mingw-binutils
  • mingw-gcc
  • mingw-gcc-core
  • mingw-gcc-g++
  • mingw-pthreads
  • mingw-runtime
  • patch (found under the Utils heading)

Check all of these packages and click Next. Cygwin will inform you that it must install additional packages to satisfy the above packages’ dependencies. Allow it to do so. Make sure that the Select Required Packages checkbox is checked before you proceed.

 

Installing libusb for the Flyswatter

Libusb is a usb driver library you will need to communicate with the Flyswatter. You will need a newer version of libusb than the one distributed through the Cygwin installer, and you will need libusb for Windows as well. Download libusb-win32-1.2.4.0 from http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download. Open the zip archive and extract the contents to C:\cygwin\home.

Navigate to the folder \libusb-win32-bin-1.2.4.0\lib\gcc. Copy the file libusb.a to C:\cygwin\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Navigate to \libusb-win32-bin-1.2.4.0\include. Copy the file usb.h to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.

 

Installing FTD2XX

Download version 2.08.14 of the D2XX Windows drivers from http://www.ftdichip.com/Drivers/D2XX.htm. Direct link is here: http://www.ftdichip.com/Drivers/CDM/CDM20814_WHQL_Certified.zip. Extract the contents to C:\cygwin\home\ftd2xx.

In Windows Explorer, open the ftd2xx folder and find the file ftd2xx.h. Copy this file to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.

Installing FTD2XX

Navigate to C:\cygwin\home\ftd2xx\i386 and find the file ftd2xx.lib. Copy it, rename the copy ftd2xx.a and copy the new file to C:\cygwin\usr\local\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Plug the Flyswatter into your computer’s USB port. The Windows Found New Hardware Wizard should appear. Choose “No, not this time” to decline to connect to Windows Update. On the next screen, choose “Install from a list of specific location.” On the third screen, choose “Search for the best drivers in these locations,” check “Include this location in the search,” and enter C:\cygwin\home\ftd2xx.

Click Next. Windows should find and install the FTDI drivers. If you see a warning that the drivers have not passed Windows Logo testing, choose “Install Anyway.”

The Found New Hardware Wizard should appear twice. The second time the wizard appears, repeat the process exactly as above.

 

 

Downloading OpenOCD

Download the OpenOCD 0.5.0 source from http://prdownload.berlios.de/openocd/openocd-0.5.0.zip and extract it to /home/openocd-0.5.0.

 

Patching OpenOCD

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 Cygwin console window, navigate to the patch file and patch the source as follows:

cd /home/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.

 

Compiling OpenOCD

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

cd /home/openocd-0.5.0./configure --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=../ftd2xx --build=i686-pc-cygwin --host=i686-pc-mingw32make

 

Preparing to Run OpenOCD

Navigate to C:\cygwin\home\openocd\src to find openocd.exe. The executable can be run from the Windows command line and does not require Cygwin.

You can run openocd from C:\cygwin\home\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 folder containing OpenOCD and its config files. Go to Start Menu > My Computer and open your C: drive. Right-click anywhere in the C: drive window and select New > Folder. Rename the new folder openocd-bin.

In another Windows Explorer window, open C:\cygwin\home\openocdcl. Click and drag to select all the contents of the folder. Right-click on any file and select Copy. Open C:\openocd-bin, right-click anywhere, and select Paste.

Now go to C:\cygwin\home\openocd\src and copy openocd.exe to C:\openocd-bin. The folder should now contain the following files and folders:

boardchipcpldcpuopenocd.exeinterfacetargettestbitsbytes.tclmemory.tclmmr_helpers.tclreadable.tcl

You can now run OpenOCD from C:\openocd-bin. To get started running OpenOCD, see Running OpenOCD on Windows.

Compiling OpenOCD v04 Linux D2XX

This guide will compile OpenOCD 0.4.0 for Ubuntu 10.04 with the FTD2XX 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 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/.

 

Installing libFTD2XX

Download version 0.4.16 of the D2XX Linux drivers from http://www.ftdichip.com. Direct link is here: http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz. This is not the most recent version of the ftd2xx library, but you will need the older version. Extract the contents to your home directory (/home/USERNAME, replacing USERNAME with your username.)

In the terminal window, navigate to ~/libftd2xx0.4.16/sample and copy the files ftd2xx.h and WinTypes.h to /usr/include. Then navigate to /usr/local/include and create symbolic links to the header files.

cd ~/libftd2xx0.4.16/samplesudo 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 ~/libftd2xx0.4.16 directory and copy the library file to /usr/local/lib. Then create symbolic links to the file in /usr/lib and /usr/local/lib:

cd ~/libftd2xx0.4.16sudo cp libftd2xx.so.0.4.16 /usr/local/libcd /usr/local/libsudo ln -s libftd2xx.so.0.4.16 libftd2xx.so.0sudo ln -s libftd2xx.so.0.4.16 libftd2xx.socd /usr/libsudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 libftd2xx.so.0sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 libftd2xx.so

Downloading OpenOCD

Download the OpenOCD 0.4.0 source from http://prdownload.berlios.de/openocd/openocd-0.4.0.tar.gz and extract openocd-0.4.0 to your home directory (/home/USERNAME/openocd-0.4.0).

 

Installing the Flyswatter 2 / Flyswatter 3 Patch (Optional)

The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and Flyswatter2, a config file for the Olimex PIC-P32MX development board, and an updated config file for the TinCanTools Hammer. Download the file Media:Openocd-fs3-b0.1.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.4.0 directory.

In the terminal window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.4.0patch -p1 -i Openocd-fs3-b0.1.patch

For more information on the config files added by this patch, see OpenOCD Config Files.

 

Compiling OpenOCD

In the terminal window, navigate to the new folder containing the OpenOCD source and run the configure script.

cd ~/openocd-0.4.0sudo ./configure --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-linux-tardir="../libftd2xx0.4.16"

This assumes that you followed this guide exactly and extracted libftd2xx0.4.16 to your /home/USERNAME directory, one level above the OpenOCD source. If this is not the case, change the value of –with-ftd2xx-linux-tardir to the path to your libftd2xx0.4.16 directory.

The configure script creates a makefile and a file called libtool, which is used to compile OpenOCD. However, a bug in libtool causes the libopenocd and ftd2xx libraries to be compiled out of order, which will cause compile errors. To fix this, open libtool in a text editor…

sudo gedit libtool

…and use the text editor’s Find command to search for…

finalize_command="$finalize_command $finalize_deplibs"

This text should appear near the end of the file, at about line 7500. Directly under this line, add the following:

compile_command='gcc -std=gnu99 -g -O2 -I~/libftd2xx0.4.16 -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -o openocd main.o ./.libs/libopenocd.a ~/libftd2xx0.4.16/static_lib/libftd2xx.a.0.4.16 -ldl -lpthread'

This puts the libopenocd and libftd2xx libraries in the correct order. Important: If you copy the above text directly from this page, be sure to delete the newlines from the text, so that it all appears as one line in libtool. The file paths in the code above assume that you have followed this guide exactly, and extracted libftd2xx to your /home directory. If this is not the case, change the file paths above to match the location of your libftd2xx0.4.16 directory.

Compile OpenOCD as follows:

sudo makesudo make install

 

Preparing to Run OpenOCD

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

You can run openocd from ~/openocd-0.4.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/tclcp -r * ~/openocd-bincd ~/openocd/srccp openocd ~/openocd-bin

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

boardchipcpldcpuopenocdinterfacetargettestbitsbytes.tclmem_helper.tclmemory.tclmmr_helpers.tcl

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

Compiling OpenOCD v04 Win7

This guide will compile OpenOCD 0.4.0 on Windows 7 with the LibFTDI driver library, for use with the TinCanTools Flyswatter. The executable created with this guide is compatible with Windows XP and Windows 7. The process is identical on 32 and 64 bit versions of Windows.

This guide makes use of the GCC cross-compiler added to Cygwin on June 2, 2011. The cross-compiler makes compiling OpenOCD for Windows much easier. Older instructions can be found at Compiling OpenOCD for Windows 7 (LibFTDI) – Pre June 2011.

 

Configuring Windows 7

OpenOCD uses a command line interface and accepts commands from a telnet client. To compile and use OpenOCD in Windows 7 you will need to enable the ‘Run’ command and telnet client. See Configuring Windows 7 for OpenOCD.

 

Installing Cygwin

Download and install Cygwin 1.7.9 from http://www.cygwin.com. Cygwin provides a GNU development environment for Windows, which will allow you to compile OpenOCD using the GNU Compiler Collection (GCC). You will not need Cygwin to run OpenOCD. The Cygwin installer is available at http://cygwin.com/install.html.

Installing Cygwin Packages

If you already have Cygwin installed, this guide recommends that you delete it and reinstall completely. Close all Cygwin windows and services and delete your Cygwin directory (by default, C:\cygwin). Then find any packages downloaded but not installed and delete them as well. You set the location of these files when you installed Cygwin. By default they appear in My Documents/Downloads. If you don’t wish to reinstall Cygwin you can find more information at http://cygwin.com/ml/cygwin/2011-06/msg00021.html.

In the Cygwin installer you will be prompted to select additional packages to install. Install the following optional packages, found under the Devel heading:

 

  • autoconf (all packages)
  • automake (all packages)
  • binutils
  • gcc
  • gcc-core
  • gcc-g++
  • git
  • libtool
  • libusb-1.0
  • libusb-win32
  • libusb-devel
  • make
  • mingw-binutils
  • mingw-gcc
  • mingw-gcc-core
  • mingw-gcc-g++
  • mingw-pthreads
  • mingw-runtime
  • patch (found under the Utils heading)

Check all of these packages and click Next. Cygwin will inform you that it must install additional packages to satisfy the above packages’ dependencies. Allow it to do so. Make sure that the Select Required Packages checkbox is checked before you proceed.

 

Installing libusb for the Flyswatter

Libusb is a usb driver library you will need to communicate with the Flyswatter. You will need a newer version of libusb than the one distributed through the Cygwin installer, and you will need libusb for Windows as well. Download libusb-win32-1.2.4.0 from http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download. Open the zip archive and extract the contents to C:\cygwin\home.

Navigate to the folder \libusb-win32-bin-1.2.4.0\lib\gcc. Copy the file libusb.a to C:\cygwin\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Navigate to \libusb-win32-bin-1.2.4.0\include. Copy the file usb.h to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.Plug the Flyswatter into your computer’s USB port. The Windows Found New Hardware Wizard will appear twice, once for each interface. Click Cancel both times.

In Windows Explorer or from the command line, navigate to \libusb-win32-bin-1.2.4.0\bin and run inf-wizard.exe. Click Next from the first screen. You should see a menu with two devices, Flyswatter (Interface 1) and Flyswatter (Interface 0). Select Flyswatter (Interface 1) and click Next twice. You will be prompted to save an .inf file to your hard drive. Click Save. On the next screen, click Install Now. You may see a warning that the driver has not been digitally signed by Microsoft. Click Yes to install anyway.

Now repeat this process for Flyswatter (Interface 0). To see if the install was successful, open the Device Manager (Start Menu > Control Panel > View By: Category > System and Security > System > Device Manager). If the install is successful, you will see two new devices labeled Flyswatter (Interface 0) and Flyswatter (Interface 1).

You may also need to install a libusb Device Filter to use OpenOCD with the Flyswatter. Follow the instructions on the libusb Device Filter page before proceeding.

 

LibFTDI

LibFTDI is an open source FTDI driver you will need to compile OpenOCD. Download libftdi-0.19.tar.gz from http://www.intra2net.com/en/developer/libftdi/download.php, and save it to C:\cygwin\home.

Open the Cygwin command line interface. The default installation will create a shortcut in your start menu, Start Menu > All Programs > Cygwin > Cygwin Bash Shell. Navigate to \home and extract libftdi using gzip:

cd /hometar -zxvf libftdi-0.19.tar.gz

In the Cygwin command console navigate to the folder where you extracted the libFTDI source.

cd /home/libftdi-0.19

Compile with the following commands. Run the first and wait for it to finish, then run the next, and so on:

./configure --build=i686-pc-cygwin --host=i686-pc-mingw32make

In Cygwin or Windows Explorer, navigate to C:\cygwin\home\libftdi-0.19\src. Find the file ftdi.h and copy it to C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include. Then in C:\cygwin\home\libftdi-0.19\src\.libs, find the file libftdi.a, and copy it to C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

 

A Note about Make Errors

With the latest version of Cygwin and its associated packages you may encounter errors with make commands. You may be able to fix these errors simply by powering through; if make gives an error, run make again. If it doesn’t halt again in the same place, you can likely proceed without worry.

You may also encounter errors with the bootstrap command used to compile OpenOCD below. Try running bootstrap again. If it passes the point where it previously halted everything is most likely fine.

 

Downloading OpenOCD

Download the OpenOCD 0.4.0 source from http://prdownload.berlios.de/openocd/openocd-0.4.0.zip and extract it to /home/openocd-0.4.0.

 

Installing the Flyswatter 2 / Flyswatter 3 Patch (Optional)

The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and Flyswatter2, a config file for the Olimex PIC-P32MX development board, and an updated config file for the TinCanTools Hammer. Download the file Media:Openocd-fs3-b0.1.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.4.0 directory.

In the Cygwin console window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.4.0patch -p1 -i Openocd-fs3-b0.1.patch

For more information on the config files added by this patch, see OpenOCD Config Files.

 

Compiling OpenOCD

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

cd /home/openocd-0.4.0./configure --disable-werror --enable-ft2232_libftdi --build=i686-pc-cygwin --host=i686-pc-mingw32make

 

Preparing to Run OpenOCD

Navigate to C:\cygwin\home\openocd\src to find openocd.exe. The executable can be run from the Windows command line and does not require Cygwin.

You can run openocd from C:\cygwin\home\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 folder containing OpenOCD and its config files. Go to Start Menu > My Computer and open your C: drive. Right-click anywhere in the C: drive window and select New > Folder. Rename the new folder openocd-bin.

In another Windows Explorer window, open C:\cygwin\home\openocdcl. Click and drag to select all the contents of the folder. Right-click on any file and select Copy. Open C:\openocd-bin, right-click anywhere, and select Paste.

Now go to C:\cygwin\home\openocd\src and copy openocd.exe to C:\openocd-bin. The folder should now contain the following files and folders:

boardchipcpldcpuopenocd.exeinterfacetargettestbitsbytes.tclmemory.tclmmr_helpers.tclreadable.tcl

You can now run OpenOCD from C:\openocd-bin. To get started running OpenOCD, see Running OpenOCD on Windows.

OpenOCD Config Files

 

This page contains OpenOCD config files created by TinCanTools. OpenOCD reads config files to configure itself for different hardware. OpenOCD is packaged with config files for many devices; the files on this page add support for new devices or replacements for obsolete config files.

 

Installing Config Files

To download a config file from this page, right-click the link and select “Save As.” Save the file somewhere in OpenOCD’s search path. If you’re not sure what directories OpenOCD searches and you compiled OpenOCD yourself, save the config file to the same directory as your OpenOCD executable. If you have installed the OpenOCD Ubuntu Package, save the config file to \usr\local\share\openocd\scripts.

You can run OpenOCD with the script like this:

openocd -f yourconfigfile.cfg -f yourotherfile.cfg

By convention, config files for processors go in a folder called /target, files for target boards go in /board, and files for interface devices go in /interface. Many config files for boards search in \target for the file for their processor, so always save files for processor to /target. You aren’t required to save your config files to \interface or /board, but it may help you keep your files organized. Just remember to include the folder in the file path when you run OpenOCD:

openocd -f interface/yourconfigfile.cfg -f board/yourotherfile.cfg

For a more in-depth discussion of how to use config files and how OpenOCD searches for them, see OpenOCD Config File Paths.

 

Flyswatter Config Files

These files add support for different versions of the TinCanTools Flyswatter. Flyswatter config files usually go in the OpenOCD’s /interface folder, although this is not required.

 

flyswatter2.cfg

This is the config file for the TinCanTools Flyswatter2. OpenOCD does not currently support the Flyswatter2; you will need to compile OpenOCD yourself to use it with the Flyswatter2. This file is included in the OpenOCD 0.5.0 Patch and the OpenOCD 0.4.0 Flyswatter 2/3 Patch.

 

 

Download flyswatter2.cfg
Right-click the link and select “Save As”

 

Full text of flyswatter2.cfg:

 

#
# TinCanTools Flyswatter
#
# http://www.tincantools.com/product.php?productid=16134
#

interface ft2232
ft2232_device_desc "Flyswatter2"
ft2232_layout "flyswatter2"
ft2232_vid_pid 0x0403 0x6010
jtag_khz 15000

 

flyswatter3.cfg

This is the config file for the TinCanTools Flyswatter3. OpenOCD does not currently support the Flyswatter3; you will need to compile OpenOCD yourself to use it with the Flyswatter3. This file is included in the OpenOCD 0.5.0 Patch and the OpenOCD 0.4.0 Flyswatter 2/3 Patch.

 

 

Download flyswatter3.cfg
Right-click the link and select “Save As”

 

Full text of flyswatter3.cfg:

 

# TinCanTools Flyswatter3
# http://www.tincantools.com

interface ft2232
ft2232_device_desc "Flyswatter3"
ft2232_layout "flyswatter3"
ft2232_vid_pid 0x0403 0x6010
jtag_khz 30000

 

flyswatter.cfg with JTAG Clock Speed

This file replaces flyswatter.cfg for the original Flyswatter. The new file sets the JTAG clock speed. This is required for OpenOCD 0.5.0 or any build based on OpenOCD 0.4.0 development code. It is not required for the 0.4.0 release. This file is included in the OpenOCD 0.5.0 Patch.

This file uses the jtag_khz command rather than the new adapter_khz command for compatibility with OpenOCD-0.4.0.

 

 

Download flyswatter.cfg
Right-click the link and select “Save As”

 

Full text of flyswatter.cfg:

 

# TinCanTools Flyswatter
# http://www.tincantools.com/product.php?productid=16134
#
# This revision of flyswatter.cfg adds the jtag_khz line,
# needed by the development version of OpenOCD available at 
# git://openocd.git.sourceforge.net/gitroot/openocd/openocd.

interface ft2232
ft2232_device_desc "Flyswatter"
ft2232_layout "flyswatter"
ft2232_vid_pid 0x0403 0x6010
jtag_khz 6000

 

 

Board Config Files

These files add support for different target boards. Board config files usually go in the OpenOCD’s /board folder, although this is not required.

hammer.cfg

This is the config file for the TinCanTools Hammer board. This is file replaces the hammer.cfg file provided with OpenOCD. It corrects the JTAG Tap Unexpected error with the old hammer.cfg by correctly setting the JTAG tap ID. This file is included in the OpenOCD 0.5.0 Patch.

 

 

Download hammer.cfg
Right-click the link and select “Save As”

 

Full text of hammer.cfg:

 

# Target Configuration for the TinCanTools S3C2410 Based Hammer Module
# http://www.tincantools.com
# This revision is an update for hammer.cfg provided with OpenOCD to
# correctly set CPUTAPID.

set CPUTAPID 0x0032409d
source [find target/samsung_s3c2410.cfg]

$_TARGETNAME configure -event reset-init {
	# Reset Script for the TinCanTools S3C2410 Based Hammer Module
	# http://www.tincantools.com
 	#
 	# Setup primary clocks and initialize the SDRAM
 	mww 0x53000000 0x00000000
 	mww 0x4a000008 0xffffffff
 	mww 0x4a00000c 0x000007ff
 	mww 0x4c000000 0x00ffffff
 	mww 0x4c000014 0x00000003
 	mww 0x4c000004 0x000a1031
 	mww 0x48000000 0x11111122
 	mww 0x48000004 0x00000700
 	mww 0x48000008 0x00000700
 	mww 0x4800000c 0x00000700
 	mww 0x48000010 0x00000700
 	mww 0x48000014 0x00000700
 	mww 0x48000018 0x00000700
 	mww 0x4800001c 0x00018005
 	mww 0x48000020 0x00018005
 	mww 0x48000024 0x009c0459
 	mww 0x48000028 0x000000b2
 	mww 0x4800002c 0x00000030
 	mww 0x48000030 0x00000030
 	flash probe 0
} 
 
 
#flash configuration
#flash bank <name> <driver> <base> <size> <chip_width> <bus_width> <target> [driver_options ...]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME cfi 0x00000000 0x1000000 2 2 $_TARGETNAME

 

olimex_pic32mx.cfg

This is the config file for the Olimex PIC-P32MX board. This very short file sets the JTAG clock speed and tap ID for the board, then calls the config file for the CPU. The CPU config file target/pic32mx.cfg is provided with OpenOCD. This file is included in the OpenOCD 0.5.0 Patch and the OpenOCD 0.4.0 Flyswatter 2/3 Patch.

This file should be used in place of the pic-p32mx.cfg file provided with OpenOCD.

 

 

Download olimex_pic32mx.cfg
Right-click the link and select “Save As”

 

Full text of olimex_pic32mx.cfg:

 

# Configuration for the Olimex PIC-32MX development board
# Config file supplied by TinCanTools
# http://www.tincantools.com

jtag_khz 15000
set CPUTAPID 0x50916053
source [find target/pic32mx.cfg]

 

 

Target Config Files

Target config files must go in a folder called /target somewhere in OpenOCD’s search path.

amdm37x.cfg

This is the config file for the am37x and dm37x processors, used with the TI Beagleboard XM in the Flyswatter2 Beagleboard XM How To. This file is almost identical to the original amdm37x.cfg file provided with OpenOCD 0.5.0. The only change is to line 32, to support JTAG TAP id 0x2b89102f. This file is included in the OpenOCD 0.5.0 Patch v0.12.

 

 

Download amdm37x.cfg
Right-click the link and select “Save As”

 

 

omap3530_norclk.cfg

OpenOCD sometimes has issues initializing the Beagleboard’s JTAG with the Flyswatter2 adaptive clocking enabled. Adaptive clocking is enabled in the config file omap3530.cfg, called from ti_beagleboard.cfg. This is a modified config file that doesn’t enable adaptive clocking. This file is intended only for use with the Beagleboard. For more information, see Beagleboard Troubleshooting: JTAG Tap Unexpected 0x000000ff.

 

 

Download omap3530_norclk.cfg
Right-click the link and select “Save As”

 

Compiling OpenOCD v04 Win7 D2XX

This guide will compile OpenOCD 0.4.0 on Windows 7 with the FTD2XX driver library, for use with the TinCanTools Flyswatter. The executable created with this guide is compatible with Windows XP and Windows 7. The process is identical on 32 and 64 bit versions of Windows.

This guide makes use of the GCC cross-compiler added to Cygwin on June 2, 2011. The cross-compiler makes compiling OpenOCD for Windows much easier. Older instructions can be found at Compiling OpenOCD for Windows 7 (FTD2XX) – Pre June 2011.

 

Configuring Windows 7

OpenOCD uses a command line interface and accepts commands from a telnet client. To compile and use OpenOCD in Windows 7 you will need to enable the ‘Run’ command and telnet client. See Configuring Windows 7 for OpenOCD.

 

Installing Cygwin

Download and install Cygwin 1.7.9 from http://www.cygwin.com. Cygwin provides a GNU development environment for Windows, which will allow you to compile OpenOCD using the GNU Compiler Collection (GCC). You will not need Cygwin to run OpenOCD. The Cygwin installer is available at http://cygwin.com/install.html.

Installing Cygwin Packages

If you already have Cygwin installed, this guide recommends that you delete it and reinstall completely. Close all Cygwin windows and services and delete your Cygwin directory (by default, C:\cygwin). Then find any packages downloaded but not installed and delete them as well. You set the location of these files when you installed Cygwin. By default they appear in My Documents/Downloads. If you don’t wish to reinstall Cygwin you can find more information at http://cygwin.com/ml/cygwin/2011-06/msg00021.html.

In the Cygwin installer you will be prompted to select additional packages to install. Install the following optional packages, found under the Devel heading:

 

  • autoconf (all packages)
  • automake (all packages)
  • binutils
  • gcc
  • gcc-core
  • gcc-g++
  • git
  • libtool
  • libusb-1.0
  • libusb-win32
  • libusb-devel
  • make
  • mingw-binutils
  • mingw-gcc
  • mingw-gcc-core
  • mingw-gcc-g++
  • mingw-pthreads
  • mingw-runtime
  • patch (found under the Utils heading)

Check all of these packages and click Next. Cygwin will inform you that it must install additional packages to satisfy the above packages’ dependencies. Allow it to do so. Make sure that the Select Required Packages checkbox is checked before you proceed.

 

Installing libusb for the Flyswatter

Libusb is a usb driver library you will need to communicate with the Flyswatter. You will need a newer version of libusb than the one distributed through the Cygwin installer, and you will need libusb for Windows as well. Download libusb-win32-1.2.4.0 from http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download. Open the zip archive and extract the contents to C:\cygwin\home.

Navigate to the folder \libusb-win32-bin-1.2.4.0\lib\gcc. Copy the file libusb.a to C:\cygwin\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Navigate to \libusb-win32-bin-1.2.4.0\include. Copy the file usb.h to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.

 

Installing FTD2XX

Download version 2.08.14 of the D2XX Windows drivers from http://www.ftdichip.com/Drivers/D2XX.htm. Direct link is here: http://www.ftdichip.com/Drivers/CDM/CDM20814_WHQL_Certified.zip. Extract the contents to C:\cygwin\home\ftd2xx.

In Windows Explorer, open the ftd2xx folder and find the file ftd2xx.h. Copy this file to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.

Installing FTD2XX

Navigate to C:\cygwin\home\ftd2xx\i386 and find the file ftd2xx.lib. Copy it, rename the copy ftd2xx.a and copy the new file to C:\cygwin\usr\local\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Plug the Flyswatter into your computer’s USB port. Install FTD2XX as follows:

  • Open the Control Panel.
  • If the View By dropdown menu in the upper right shows Category, change it to Large Icons or Small Icons.
  • Click System.
  • Click Device Manager on the left.
  • Find the Flyswatter devices. There should be two of them.
  • Right click the first Flyswatter device and select Update Driver Software.
  • Choose Browse my computer for driver software.
  • Click Browse.
  • Navigate to C:/cygwin/home/ftd2xx.
  • Click OK. The panel should now look like the screenshot to the right.
  • Click Next and wait for the install to complete.
  • Repeat the process for the other Flyswatter device.

 

A Note about Make Errors

With the latest version of Cygwin and its associated packages you may encounter errors with make commands. You may be able to fix these errors simply by powering through; if make gives an error, run make again. If it doesn’t halt again in the same place, you can likely proceed without worry.

You may also encounter errors with the bootstrap command used to compile OpenOCD below. Try running bootstrap again. If it passes the point where it previously halted everything is most likely fine.

 

Downloading OpenOCD

Download the OpenOCD 0.4.0 source from http://prdownload.berlios.de/openocd/openocd-0.4.0.zip and extract it to /home/openocd-0.4.0.

 

Installing the Flyswatter 2 / Flyswatter 3 Patch (Optional)

The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and Flyswatter2, a config file for the Olimex PIC-P32MX development board, and an updated config file for the TinCanTools Hammer. Download the file Media:Openocd-fs3-b0.1.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.4.0 directory.

In the Cygwin console window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.4.0patch -p1 -i Openocd-fs3-b0.1.patch

For more information on the config files added by this patch, see OpenOCD Config Files.

 

Compiling OpenOCD

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

cd /home/openocd-0.4.0./configure --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=../ftd2xx --build=i686-pc-cygwin --host=i686-pc-mingw32make

 

Preparing to Run OpenOCD

Navigate to C:\cygwin\home\openocd\src to find openocd.exe. The executable can be run from the Windows command line and does not require Cygwin.

You can run openocd from C:\cygwin\home\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 folder containing OpenOCD and its config files. Go to Start Menu > My Computer and open your C: drive. Right-click anywhere in the C: drive window and select New > Folder. Rename the new folder openocd-bin.

In another Windows Explorer window, open C:\cygwin\home\openocdcl. Click and drag to select all the contents of the folder. Right-click on any file and select Copy. Open C:\openocd-bin, right-click anywhere, and select Paste.

Now go to C:\cygwin\home\openocd\src and copy openocd.exe to C:\openocd-bin. The folder should now contain the following files and folders:

boardchipcpldcpuopenocd.exeinterfacetargettestbitsbytes.tclmemory.tclmmr_helpers.tclreadable.tcl

You can now run OpenOCD from C:\openocd-bin. To get started running OpenOCD, see Running OpenOCD on Windows.

OpenOCD Patches

 

TinCanTools provides patches for the OpenOCD source to add support for the Flyswatter2 and Flyswatter3. These patches also contain config files for use with other guides on this wiki.

Patches on this page are linked directly from the guides on Compiling OpenOCD.

 

Reading the Content of Patches

OpenOCD are created by the Linux program diff. Diff files are in text format. You can see the changes made by a patch on this page by simply opening and reading it in a text editor. Lines added to files are proceeded by a + sign.

The full text of all config files can also be found on the OpenOCD Config Files page.

 

OpenOCD 0.5.0 Patch

Target: OpenOCD 0.5.0 source

Version: b0.11

Format: diff

Description: This patch adds support for the Flyswatter2 and Flyswatter3, updates the config file for the Flyswatter and the Hammer, and adds a new config file for the Olimex PIC-P32MX board.

Install: Save to /openocd-0.5.0, the directory containing the OpenOCD source. Then open a terminal window and type:

$ cd ~/openocd-0.5.0
$ patch -p1 -i Tincantools-openocd-b0.12.patch

 

 

Download Tincantools-openocd-b0.12.patch
Right-click the link and select “Save As”

 

Files Modified:

Files Created:

 

Version Changes
0.12 Added amdm37x.cfg
corrected flyswatter3_init() error messages in ft2232.c
0.11

 

OpenOCD 0.4.0 Flyswatter 2/3 Patch

Target: OpenOCD 0.4.0 source

Version: b0.1

Format: diff

Description: This patch adds support for the Flyswatter2 and Flyswatter3 in OpenOCD 0.4.0, and adds a new config file for the Olimex PIC-P32MX board.

Install: Save to /openocd-0.4.0, the directory containing the OpenOCD source. Then open a terminal window and type:

$ cd ~/openocd-0.4.0
$ patch -p1 -i Openocd-fs3-b0.1.patch

 

 

Download Openocd-fs3-b0.1.patch
Right-click the link and select “Save As”

 

Files Modified:

  • src/jtag/drivers/ft2232.c

Files Created:

 

External Links

diff man page
patch man page

Compiling OpenOCD v04 WinXP

This guide will compile OpenOCD 0.4.0 on Windows XP with the LibFTDI driver library, for use with the TinCanTools Flyswatter. The executable created with this guide is compatible with Windows XP and Windows 7. The process is identical on 32 and 64 bit versions of Windows.

This guide makes use of the GCC cross-compiler added to Cygwin on June 2, 2011. The cross-compiler makes compiling OpenOCD for Windows much easier. Older instructions can be found at Compiling OpenOCD for Windows XP (LibFTDI) – Pre June 2011.

 

 

Installing Cygwin

Download and install Cygwin 1.7.9 from http://www.cygwin.com. Cygwin provides a GNU development environment for Windows, which will allow you to compile OpenOCD using the GNU Compiler Collection (GCC). You will not need Cygwin to run OpenOCD. The Cygwin installer is available at http://cygwin.com/install.html.

Installing Cygwin Packages

If you already have Cygwin installed, this guide recommends that you delete it and reinstall completely. Close all Cygwin windows and services and delete your Cygwin directory (by default, C:\cygwin). Then find any packages downloaded but not installed and delete them as well. You set the location of these files when you installed Cygwin. By default they appear in My Documents/Downloads. If you don’t wish to reinstall Cygwin you can find more information at http://cygwin.com/ml/cygwin/2011-06/msg00021.html.

In the Cygwin installer you will be prompted to select additional packages to install. Install the following optional packages, found under the Devel heading:

 

  • autoconf (all packages)
  • automake (all packages)
  • binutils
  • gcc
  • gcc-core
  • gcc-g++
  • git
  • libtool
  • libusb-1.0
  • libusb-win32
  • libusb-devel
  • make
  • mingw-binutils
  • mingw-gcc
  • mingw-gcc-core
  • mingw-gcc-g++
  • mingw-pthreads
  • mingw-runtime
  • patch (found under the Utils heading)

Check all of these packages and click Next. Cygwin will inform you that it must install additional packages to satisfy the above packages’ dependencies. Allow it to do so. Make sure that the Select Required Packages checkbox is checked before you proceed.

 

Installing libusb for the Flyswatter

Libusb is a usb driver library you will need to communicate with the Flyswatter. You will need a newer version of libusb than the one distributed through the Cygwin installer, and you will need libusb for Windows as well. Download libusb-win32-1.2.4.0 from http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download. Open the zip archive and extract the contents to C:\cygwin\home.

Navigate to the folder \libusb-win32-bin-1.2.4.0\lib\gcc. Copy the file libusb.a to C:\cygwin\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Navigate to \libusb-win32-bin-1.2.4.0\include. Copy the file usb.h to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.Plug the Flyswatter into your computer’s USB port. The Windows Found New Hardware Wizard will appear twice, once for each interface. Click Cancel both times.

In Windows Explorer or from the command line, navigate to \libusb-win32-bin-1.2.4.0\bin and run inf-wizard.exe. Click Next from the first screen. You should see a menu with two devices, Flyswatter (Interface 1) and Flyswatter (Interface 0). Select Flyswatter (Interface 1) and click Next twice. You will be prompted to save an .inf file to your hard drive. Click Save. On the next screen, click Install Now. You may see a warning that the driver has not been digitally signed by Microsoft. Click Yes to install anyway.

Now repeat this process for Flyswatter (Interface 0). To see if the install was successful, open the Device Manager (Start Menu > Control Panel > System > Hardware tab > Device Manager). If the install is successful, you will see two new devices labeled Flyswatter (Interface 0) and Flyswatter (Interface 1).

You may also need to install a libusb Device Filter to use OpenOCD with the Flyswatter. Follow the instructions on the libusb Device Filter page before proceeding.

 

LibFTDI

LibFTDI is an open source FTDI driver you will need to compile OpenOCD. Download libftdi-0.19.tar.gz from http://www.intra2net.com/en/developer/libftdi/download.php, and save it to C:\cygwin\home.

Open the Cygwin command line interface. The default installation will create a shortcut in your start menu, Start Menu > All Programs > Cygwin > Cygwin Bash Shell. Navigate to \home and extract libftdi using gzip:

cd /hometar -zxvf libftdi-0.19.tar.gz

In the Cygwin command console navigate to the folder where you extracted the libFTDI source.

cd /home/libftdi-0.19

Compile with the following commands. Run the first and wait for it to finish, then run the next, and so on:

./configure --build=i686-pc-cygwin --host=i686-pc-mingw32make

In Cygwin or Windows Explorer, navigate to C:\cygwin\home\libftdi-0.19\src. Find the file ftdi.h and copy it to C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include. Then in C:\cygwin\home\libftdi-0.19\src\.libs, find the file libftdi.a, and copy it to C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

 

A Note about Make Errors

With the latest version of Cygwin and its associated packages you may encounter errors with make commands. You may be able to fix these errors simply by powering through; if make gives an error, run make again. If it doesn’t halt again in the same place, you can likely proceed without worry.

You may also encounter errors with the bootstrap command used to compile OpenOCD below. Try running bootstrap again. If it passes the point where it previously halted everything is most likely fine.

 

Downloading OpenOCD

Download the OpenOCD 0.4.0 source from http://prdownload.berlios.de/openocd/openocd-0.4.0.zip and extract it to /home/openocd-0.4.0.

 

Installing the Flyswatter 2 / Flyswatter 3 Patch (Optional)

The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and Flyswatter2, a config file for the Olimex PIC-P32MX development board, and an updated config file for the TinCanTools Hammer. Download the file Media:Openocd-fs3-b0.1.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.4.0 directory.

In the Cygwin console window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.4.0patch -p1 -i Openocd-fs3-b0.1.patch

For more information on the config files added by this patch, see OpenOCD Config Files.

 

Compiling OpenOCD

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

cd /home/openocd-0.4.0./configure --disable-werror --enable-ft2232_libftdi --build=i686-pc-cygwin --host=i686-pc-mingw32make

 

Preparing to Run OpenOCD

Navigate to C:\cygwin\home\openocd\src to find openocd.exe. The executable can be run from the Windows command line and does not require Cygwin.

You can run openocd from C:\cygwin\home\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 folder containing OpenOCD and its config files. Go to Start Menu > My Computer and open your C: drive. Right-click anywhere in the C: drive window and select New > Folder. Rename the new folder openocd-bin.

In another Windows Explorer window, open C:\cygwin\home\openocdcl. Click and drag to select all the contents of the folder. Right-click on any file and select Copy. Open C:\openocd-bin, right-click anywhere, and select Paste.

Now go to C:\cygwin\home\openocd\src and copy openocd.exe to C:\openocd-bin. The folder should now contain the following files and folders:

boardchipcpldcpuopenocd.exeinterfacetargettestbitsbytes.tclmemory.tclmmr_helpers.tclreadable.tcl

You can now run OpenOCD from C:\openocd-bin. To get started running OpenOCD, see Running OpenOCD on Windows.

OpenOCD Ubuntu Package

As an alternative to compiling OpenOCD from source, OpenOCD is available via Ubuntu’s Advanced Packaging Tool (APT). Ubuntu 10.04 users can download and install OpenOCD using the apt-get command.

 

Flyswatter2 Support

This package is based on the OpenOCD 0.4.0 release available at http://prdownload.berlios.de/openocd/openocd-0.4.0.tar.gz. It does not include support for the TinCanTools Flyswatter2. To compile OpenOCD with Flyswatter2 support, see Compiling OpenOCD Linux for Flyswatter2.

 

Installing the OpenOCD Package

Open a terminal window (Applications menu > Accessories > Terminal) and type:

sudo apt-get install openocd

The Ubuntu APT will install OpenOCD and its config files to your computer. As with any command using sudo, you will need an administrator password to run this command.

 

Linking to /usr/share/openocd

The package installs config files to /usr/share/openocd/scripts, but OpenOCD looks for config files in /usr/local/share/openocd/scripts. Fix that now by creating a symbolic link in /usr/local/share to /usr/share/openocd. In the terminal window, type:

cd /usr/local/share
sudo ln -s /usr/share/openocd .

OpenOCD will now be able to find its config files. For more information on how OpenOCD searches for config files, see OpenOCD Config File Paths.

 

Running OpenOCD

You can run OpenOCD from a terminal window from any directory. Installing OpenOCD from the APT allows users to run OpenOCD without sudo. (If you compiled OpenOCD yourself you would need to take special steps to allow users to use OpenOCD without sudo.

In a terminal window, type:

openocd -f path_to/file.cfg [-f another_path_to/file2.cfg]

For example, to run OpenOCD for the TinCanTools Flyswatter and Hammer, type:

openocd -f interface/flyswatter.cfg -f board/hammer.cfg

To get started, see Running OpenOCD on Linux. If you encounter errors, see OpenOCD Troubleshooting.