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

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

 

 

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.

OpenOCD

OpenOCD (Open On-Chip Debugger) is open-source software that interfaces with the Flyswatter’s JTAG port. OpenOCD provides debugging and in-system programming for embedded target devices. OpenOCD provides the ability to flash NAND and NOR FLASH memory devices that are attached to the processor on the target system. Flash programming is supported for external CFI compatible flashes (Intel and AMD/Spansion command set) and several internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3 and STM32x).

OpenOCD supports the following cores:

CORE TYPE EXAMPLE PROCESSORS
ARM7TDMI LPC2148, AT91SAM7
ARM720T LH79520, EP7312
ARM9TDMI
ARM920T S3C2410, S3C2440
ARM922T
ARM926EJS S3C2412, STN8811, STN8815
ARM966E STR91XF
ARM11 S3C6400, OMAP2420, MSM7200
ARM1136
ARM1156
ARM1176
CORTEX-M3 LM3S series, STM32 series
CORTEX-A8 OMAP3530 BeagleBoard
CORTEX-A8 DM3730 BeagleBoard-xM
CORTEX-A9 OMAP4430 PandaBoard
XSCALE PXA255, PXA270, IXP42X
MARVEL FEROCEON CPU CORE
MIPS M4K

OpenOCD was originally developed by Dominic Rath at the University of Applied Sciences Augsburg. The OpenOCD source code is now available through the GNU General Public License (GPL).

Installing OpenOCD

Compiling OpenOCD

OpenOCD Ubuntu Package

OpenOCD Patches

OpenOCD Config Files

 

Running OpenOCD

Running OpenOCD on Linux

Running OpenOCD on Windows

OpenOCD Troubleshooting

 

External Links

OpenOCD website: http://openocd.sourceforge.net/

OpenOCD source: http://sourceforge.net/projects/openocd/files/openocd/0.7.0/openocd-0.7.0.tar.gz/download

GNU GPL (OpenOCD license): http://www.gnu.org/licenses/gpl.html

Minicom

Minicom is a Linux program you can use to communicate with embedded target devices, either directly via through your computer’s COM port or with the Flyswatter. This guide is written for Flyswatter and the Beagleboard. Configuration is similar for other target boards.

Minicom is available through the Ubuntu Advanced Packaging Tool (APT).

Configuring Minicom

Install minicom using apt-get. Open a terminal window and type:

$ sudo apt-get install minicom

Run minicom setup as root from the host computer:

$ sudo minicom -s

You'll get a screen as follows:

           +-----[configuration]------+                                        
           | Filenames and paths      |                                        
           | File transfer protocols  |                                        
           | Serial port setup        |                                        
           | Modem and dialing        |                                        
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+                                        

Select Serial port setup:

   +-----------------------------------------------------------------------+   
   | A -    Serial Device      : /dev/ttyS1                                |   
   | B - Lockfile Location     : /var/lock                                 |   
   | C -   Callin Program      :                                           |   
   | D -  Callout Program      :                                           |   
   | E -    Bps/Par/Bits       : 9600 8N1                                  |   
   | F - Hardware Flow Control : Yes                                       |   
   | G - Software Flow Control : No                                        |   
   |                                                                       |   
   |    Change which setting?                                              |   
   +-----------------------------------------------------------------------+   
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+                                        

Now press E to change those settings:

                   +-----------[Comm Parameters]------------+                  
   +---------------|                                        |--------------+   
   | A -    Serial | Current: 115200 8N1                    |              |   
   | B - Lockfile L|                                        |              |   
   | C -   Callin P|   Speed          Parity          Data  |              |   
   | D -  Callout P|                                        |              |   
   | E -    Bps/Par| A: 300           L: None         S: 5  |              |   
   | F - Hardware F| B: 1200          M: Even         T: 6  |              |   
   | G - Software F| C: 2400          N: Odd          U: 7  |              |   
   |               | D: 4800          O: Mark         V: 8  |              |   
   |    Change whic| E: 9600          P: Space              |              |   
   +---------------| F: 19200                      Stopbits |--------------+   
           | Screen| G: 38400                         W: 1  |                  
           | Save s| H: 57600                         X: 2  |                  
           | Save s| I: 115200        Q: 8-N-1              |                  
           | Exit  | J: 230400        R: 7-E-1              |                  
           | Exit f|                                        |                  
           +-------|                                        |                  
                   | Choice, or <Enter> to exit?            |                  
                   +----------------------------------------+                  

You should get 115200 8N1, press keys I, L, V and W. When you’re done, press Enter.

Now in the previous screen, press F to set Hardware Flow Control to Off. You should have this now:

   +-----------------------------------------------------------------------+   
   | A -    Serial Device      : /dev/ttyS1                                |   
   | B - Lockfile Location     : /var/lock                                 |   
   | C -   Callin Program      :                                           |   
   | D -  Callout Program      :                                           |   
   | E -    Bps/Par/Bits       : 115200 8N1                                |   
   | F - Hardware Flow Control : No                                        |   
   | G - Software Flow Control : No                                        |   
   |                                                                       |   
   |    Change which setting?                                              |   
   +-----------------------------------------------------------------------+   
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+                   

Now press A to change the serial device, and type /dev/ttyUSB0.

   +-----------------------------------------------------------------------+
   | A -    Serial Device      : /dev/ttyUSB0                              |
   | B - Lockfile Location     : /var/lock                                 |
   | C -   Callin Program      :                                           |
   | D -  Callout Program      :                                           |
   | E -    Bps/Par/Bits       : 115200 8N1                                |
   | F - Hardware Flow Control : No                                        |
   | G - Software Flow Control : No                                        |
   |                                                                       |
   |    Change which setting?                                              |
   +-----------------------------------------------------------------------+
           | Screen and keyboard      |                                  
           | Save setup as dfl        |                                  
           | Save setup as..          |                                  
           | Exit                     |                                  
           +--------------------------+                                                 
                                                                               

Press Enter to leave this screen, select Save setup as dfl and finally select Exit from Minicom.

Connecting to the Beagleboard with Minicom

Connect the Flyswatter and the Beagleboard and connect the Beagleboard to your computer’s USB port, as described in the Flyswatter How To. Then run minicom as root:

$ sudo minicom

You should get the following screen:

Welcome to minicom 2.2

OPTIONS:                                                                     
Compiled on Sep  8 2008, 17:03:34.                                           
Port /dev/ttyUSB1                                                              
                                                                            
              Press CTRL-A Z for help on special keys                       
                                                                            
                                                                            
                                                                            
Texas Instruments X-Loader 1.41                                              
Starting OS Bootloader...                                                    
                                        
U-Boot 1.3.3 (Jul 10 2008 - 16:33:09)   
                                        
OMAP3530-GP rev 2, CPU-OPP2 L3-165MHz   
OMAP3 Beagle Board + LPDDR/NAND         
DRAM:  128 MB                           
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Audio Tone on Speakers  ... complete
OMAP3 beagleboard.org # 

If you don’t, check the serial port. You’ll have to go back to the config (minicom -s) and get to this screen:

   +-----------------------------------------------------------------------+   
   | A -    Serial Device      : /dev/ttyUSB0                              |   
   | B - Lockfile Location     : /var/lock                                 |   
   | C -   Callin Program      :                                           |   
   | D -  Callout Program      :                                           |   
   | E -    Bps/Par/Bits       : 115200 8N1                                |   
   | F - Hardware Flow Control : No                                        |   
   | G - Software Flow Control : No                                        |   
   |                                                                       |   
   |    Change which setting?                                              |   
   +-----------------------------------------------------------------------+   
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+     

Now press A and change /dev/ttyUSB0 for /dev/ttyUSB1, save as dfl, and restart minicom.

If you still don’t get the beagleboard shell, try using other serial terminal program like GtkTerm.

Now we got the beagleboard shell! Congratulations!

First command we wanna try is “help”:

OMAP3 beagleboard.org # help

If you get some output, you’re happy!

If at some point you cannot enter text any more, verify that you have turned off flow control (F and G should be set to No). Also if after a reboot you do not see anything exit (ctrl-A q) and restart minicom.

Flyswatter How To

This guide is for Ubuntu 10.04. For the Windows guide, see Flyswatter Windows How To.

This guide will walk you through connecting the Flyswatter and the Beagleboard to your Linux PC, and installing and running OpenOCD. This guide was written with Ubuntu 10.04.

 

Connecting the Flyswatter and the Beagleboard

To hook up the Flyswatter and the Beagleboard, you will need:

  • Flyswatter
    • USB Male A/Male B cable
    • 14-pin JTAG Ribbon Cable
  • Beagleboard
    • 5V1A Power Supply
  • Beagleboard Adapter Kit (product link)
    • JTAG Adapter Board
    • RS-232 Adapter Board
    • 10-pin Ribbon Cable

The cables listed under the Flyswatter ship with the Flyswatter.

 

Connect the RS-232 adapter board to the Flyswatter.

Take the RS-232 adapter board provided in the Beagleboard adapter kit, and connect it to the Flyswatter’s serial UART interface.

Flyswatter RS232adapter.png

 

Connect the 10-pin cable to the Flyswatter.

The adapter board above allows you to connect the 10-pin ribbon cable in the Beagleboard adapter kit to the Flyswatter. Do that now. Pay careful attention to the position of the red stripe. The red stripe should line up with the “1” printed on the adapter board, as in the picture below.

Flyswatter RS232cable.png

 

Connect the other end of the cable to the Beagleboard.

Connect the 10-pin RS-232 cable to the pins to the side of the Beagleboard, the ones next to the power adapter. Make sure the cable is correctly centered over the pins, and again pay attention to the red stripe. It should match up with the “1” printed on the Beagleboard.

Both RS232.png

 

Connect the JTAG adapter board to the Flyswatter.

Find the JTAG adapter board included in the Beagleboard adapter kit, and plug it into the Flyswatter’s JTAG interface. The adapter board should hang out over the edge of the Flyswatter.

Flyswatter jtagadapter.png

 

Connect the Flyswatter and the Beagleboard with the JTAG cable.

Find the 14-pin JTAG ribbon cable that comes with the Flyswatter. Connect one end to the JTAG adapter board, and the other end to the diagonal pins on the Beagleboard. Make sure the red stripe lines up with the “1” printed next to the pins on the Beagleboard, like in the picture.

Bothcables.png

 

Connect the USB cable to the Flyswatter.

Find the USB cable that comes with the Flyswatter. Connect the B end (the square end, not the flat end) to the Flyswatter.

Flyswatter usb.png

 

Connect the power supply to the Beagleboard.

Connect the 5V1A power supply to the Beagleboard. (Your power supply may not look exactly like the one pictured.)

Beagle power.png

 

Plug the power cable into a surge protector or wall outlet.

Green LEDs should light up on the Beagleboard to indicate that it is receiving power.

Both beaglelit.png

 

Plug the USB cable into your PC’s USB port.

You should see the green outermost LED on the Flyswatter light up, to indicate that the Flyswatter is receiving power through the USB connection.

Both lit.png

 

Installing OpenOCD

OpenOCD (Open On-Chip Debugger) is open-source software that interfaces with the Flyswatter. OpenOCD provides debugging and in-system programming for embedded target devices. You will need to install OpenOCD, either from Ubuntu’s packaging tool or by compiling it yourself.

The easiest way to get OpenOCD is to install it with apt-get. To install OpenOCD with apt-get, follow these instructions:
OpenOCD Ubuntu Package
To compile OpenOCD yourself, follow one of these guides:
Compiling OpenOCD Linux

Compiling OpenOCD Linux D2XX
The first set of instructions uses libFTDI, an open-source driver library for FTDI devices. The second set uses FTD2XX, a closed-source driver library from Future Technology Devices International.

 

Running OpenOCD

Now you are ready to run OpenOCD. If you installed the OpenOCD Ubuntu package, open a terminal window and type the following from any directory:

openocd -f interface/flyswatter.cfg -f board/ti_beagleboard.cfg -c init -c "reset init"

If you compiled OpenOCD yourself, navigate to the openocd-bin directory you created in the compile guide and type:

cd ~/openocd-bin
sudo ./openocd -f interface/flyswatter.cfg -f board/ti_beagleboard.cfg -c init -c "reset init"

For more information, see Running OpenOCD on Linux. When you start OpenOCD, its output should look like this:

Beagle startup.png

JTAG-DP_STICKY_ERROR on startup

The -c init -c “reset init” commands in the OpenOCD startup are a workaround for a bug in OpenOCD that affects the Beagleboard and TI Beagleboard XM. If you start OpenOCD without these commands, you will see errors like this:

Beagle startup err.png

If you see these errors, then the next time you try to start OpenOCD it will give an error the next time it tries to communicate with the Beagleboard. When you exit OpenOCD you will need to disconnect and reconnect the power cable to the Flyswatter before OpenOCD will be able to communicate with the Beagleboard again.

JTAG Tap Unexpected Errors

On startup you may sometimes encounter this error:

Info : JTAG tap: omap3530.jrc tap/device found: 0x000000ff (mfg: 0x07f, part: 0x0000, ver: 0x0)
Warn : JTAG tap: omap3530.jrc       UNEXPECTED: 0x000000ff (mfg: 0x07f, part: 0x0000, ver: 0x0)
Error: JTAG tap: omap3530.jrc  expected 1 of 1: 0x0b7ae02f (mfg: 0x017, part: 0xb7ae, ver: 0x0)

This output means OpenOCD has failed to initialize the JTAG chain. The -c init -c “reset init” commands are a partial workaround for this error. Look for the following line later in the output:

 Info : JTAG tap: omap3530.jrc tap/device found: 0x0b7ae02f (mfg: 0x017, part: 0xb7ae, ver: 0x0)

If you see this line, everything is fine.

Troubleshooting

Getting OpenOCD to initialize JTAG correctly with the Beagleboard is sometimes difficult. If you are having difficulties beyond those described above, consult the troubleshooting page below.

Beagleboard Troubleshooting: JTAG Tap Unexpected

Telnet Connection

You cannot enter commands directly to OpenOCD. Open a new terminal window and type:

telnet localhost 4444

You will should see this prompt:

Telnet.png

You can give commands to OpenOCD through this prompt.

 

Common OpenOCD Commands

To see a full list of OpenOCD commands, enter help in the telnet window.

reset

Resets the Beagleboard. The output of the Reset command should look like this:

Reset.png

halt

Sends a halt request to the Beagleboard. If the Beagleboard halts, you will see text output in the telnet window. (If the Beagleboard is already halted, you will see no output.)

Halt.png

halt [timeout]

You can also use halt followed by a time in milliseconds. OpenOCD waits for the target to halt the specified amount of time, then gives up if the target has not halted. You can use this to avoid OpenOCD hanging because the Beagleboard fails to halt. For example, to send a halt command with a timeout of one second, type:

halt 1000

resume

Enter resume to end a halt. You will not see any text output in the telnet window.

reg

Displays a numbered list of all of the Beagleboard’s registers.

Reg.png

reg [entry]

Run reg with a register number to display the contents of a register, in hexadecimal. The register number corresponds to the output of the reg command with no arguments, above. You must run the halt command before reading registers.

Reg0.png

If you run reg while the Beagleboard is not halted, you will still see the value stored in the register. However, registers change contents very quickly while the device is running; by the time you see the value, the value actually in the register may be different. If you try to run reg while the device is not halted, you will see this:

Reg0 not halted.png

 

reg [entry] [value]

Sets the value of a register. The register number corresponds to the output of the reg command with no arguments, above. Make sure the Beagleboard is halted (with the halt command) before you change the value of a register!

You can enter registry values in either decimal, by typing a number by itself, or in hexadecimal, by prefacing the value with 0x.

Regset.png

 

GDB Debugger

GDB, the GNU Project Debugger is a debugging tool provided with the GNU Compiler Collection (GCC). GDB allows you to stop and start a running program, examine its functioning, and make changes. GDB is installed on Ubuntu 10.04 by default, but you will need a different version of GDB build for embedded targets. Follow the instructions on the GDB Debugger page below.

GDB Debugger

The GDB debugger page will walk you through installing GDB for use with OpenOCD, and loading and testing a simple program.