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 v06 Win7

This guide will compile OpenOCD 0.6.0 on Windows 7 with the LibFTDI driver library, for use with the TinCanTools Flyswatter, Flyswatter2, and Flyswatter3. 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.

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 WinXP or Compiling OpenOCD Win7.

 

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 WinXP or Compiling OpenOCD Win7 instead.

 

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.

 

 

Downloading OpenOCD

Git is version control software available as a Cygwin package. You already installed this software above. You can use git to download the current development code from the OpenOCD git repository at sourceforge.net. In the Cygwin console 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/.

 

Compiling OpenOCD

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

cd /home/openocd./bootstrap./configure --enable-maintainer-mode --disable-werror --enable-ft2232_libftdi --build=i686-pc-cygwin --host=i686-pc-mingw32makemake install

Navigate to /home/openocd/src to find the openocd binary. You can run the binary from the Windows command line interface without using Cygwin.

 

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 v06 Win7 D2XX

This guide will compile OpenOCD 0.6.0 on Windows 7 with the FTD2XX driver library, for use with the TinCanTools Flyswatter, Flyswatter2, and Flyswatter3. 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.

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 WinXP or Compiling OpenOCD Win7.

 

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 WinXP or Compiling OpenOCD Win7 instead.

 

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.

 

 

Downloading OpenOCD

Git is version control software available as a Cygwin package. You already installed this software above. You can use git to download the current development code from the OpenOCD git repository at sourceforge.net. In the Cygwin console 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/.

 

Compiling OpenOCD

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

cd /home/openocd./bootstrap./configure --enable-maintainer-mode --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=../ftd2xx --build=i686-pc-cygwin --host=i686-pc-mingw32makemake install

Navigate to /home/openocd/src to find the openocd binary. You can run the binary from the Windows command line interface without using Cygwin.

 

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 v06 WinXP

This guide will compile OpenOCD 0.6.0 on Windows XP with the LibFTDI driver library, for use with the TinCanTools Flyswatter, Flyswatter2, and Flyswatter3. 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.

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 WinXP or Compiling OpenOCD Win7.

 

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 WinXP or Compiling OpenOCD Win7 instead.

 

 

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.

 

 

Downloading OpenOCD

Git is version control software available as a Cygwin package. You already installed this software above. You can use git to download the current development code from the OpenOCD git repository at sourceforge.net. In the Cygwin console 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/.

 

Compiling OpenOCD

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

cd /home/openocd./bootstrap./configure --enable-maintainer-mode --disable-werror --enable-ft2232_libftdi --build=i686-pc-cygwin --host=i686-pc-mingw32makemake install

Navigate to /home/openocd/src to find the openocd binary. You can run the binary from the Windows command line interface without using Cygwin.

 

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 v06 WinXP D2XX

This guide will compile OpenOCD 0.6.0 on Windows XP with the FTD2XX driver library, for use with the TinCanTools Flyswatter, Flyswatter2, and Flyswatter3. 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.

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 WinXP or Compiling OpenOCD Win7.

 

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 WinXP or Compiling OpenOCD Win7 instead.

 

 

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

Git is version control software available as a Cygwin package. You already installed this software above. You can use git to download the current development code from the OpenOCD git repository at sourceforge.net. In the Cygwin console 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/.

 

Compiling OpenOCD

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

cd /home/openocd./bootstrap./configure --enable-maintainer-mode --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=../ftd2xx --build=i686-pc-cygwin --host=i686-pc-mingw32makemake install

Navigate to /home/openocd/src to find the openocd binary. You can run the binary from the Windows command line interface without using Cygwin.

 

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 v07 Linux

This guide will compile OpenOCD version 0.7.0 for use on Ubuntu 12.04 LTS with the open source LibFTDI driver library, for use with the TinCanTools Flyswatter2 and Flyswatter. This is the most recent release version of OpenOCD.

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 communicate with 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/libftdi-0.19.tar.gz 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 v0.70 source from:http://sourceforge.net/projects/openocd/files/openocd/0.7.0/openocd-0.7.0.tar.gz/download

and extract it to /home/USERNAME/openocd-0.7.0. (replacing USERNAME with your username).

Compiling OpenOCD

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

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

Navigate to /home/USERNAME/openocd-0.7.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.7.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.7.0/tclcp -r * ~/openocd-bincd ~/openocd-0.7.0/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.

Compile OpenOCD

Guides for compiling OpenOCD for use with the TinCanTools Flyswatter and Flyswatter2 are available here.

 

OpenOCD Version 0.7.0 (we recommend installing this version of OpenOCD)

Version 0.7.0 was released on May 18, 2013. It is the newest release of OpenOCD. This guide will show you how to download, compile and install OpenOCD.

Ubuntu 12.04 LTS

Compiling OpenOCD v07 Linux – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v07 Linux D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

Version 0.6.0

0.6.0 is the version of OpenOCD currently in development. These guides use most recent revision of the source code, downloaded from the git repository at git://openocd.git.sourceforge.net/gitroot/openocd/openocd. This version has the advantage of already including support for the Flyswatter2 and Flyswatter3, but the code is subject to change at any time. If you have trouble with any of these guides try OpenOCD 0.5.0 instead.

Windows 7

Also use these instructions if compiling on Windows Vista.

Compiling OpenOCD v06 Win7 – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v06 Win7 D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

Windows XP

Compiling OpenOCD v06 WinXP – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v06 WinXP D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

Ubuntu 10.04

Compiling OpenOCD v06 Linux – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v06 Linux D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

OpenOCD Version 0.5.0

Version 0.5.0 was released May 9, 2011. It is strongly recommended that you build OpenOCD version 0.7.0 instead.

OpenOCD 0.5.0 does not include support for the Flyswatter2 or Flyswatter3. These guides include instructions on applying a patch to add Flyswatter2/Flyswatter3 support.

Windows 7

Also use these instructions if compiling on Windows Vista.

Compiling OpenOCD Win7 – This guide uses the libFTDI open source driver library.

Compiling OpenOCD Win7 D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

Windows XP

Compiling OpenOCD WinXP – This guide uses the libFTDI open source driver library.

Compiling OpenOCD WinXP D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

Ubuntu 10.04

Compiling OpenOCD Linux – This guide uses the libFTDI open source driver library.

Compiling OpenOCD Linux D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

OpenOCD Version 0.4.0

Version 0.4.0 was released May 2011. It is strongly recommended that you build version 0.7.0 instead.

Windows 7

Compiling OpenOCD v04 Win7 – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v04 Win7 D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

Windows XP

Compiling OpenOCD v04 WinXP – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v04 WinXP D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

Ubuntu 10.04

Compiling OpenOCD v04 Linux – This guide uses the libFTDI open source driver library.

Compiling OpenOCD v04 Linux D2XX – This guide uses the D2XX driver library from Future Technology Devices International.

 

OpenOCD Ubuntu Package – OpenOCD is also available through the Ubuntu package if you wish to install with apt-get rather than compiling it yourself. This package does not include support for the Flyswatter2 or Flyswatter3.

Compiling OpenOCD Win7

This guide will compile OpenOCD 0.5.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.

 

 

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_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.

Compiling OpenOCD Win7 D2XX

This guide will compile OpenOCD 0.5.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.

 

 

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 Linux D2XX

This guide will compile OpenOCD 0.5.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 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

 

Downloading OpenOCD

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).

 

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_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:

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.