This guide is out of date. Because of the recent addition of a cross-compiler to Cygwin, these instructions apply only to a user with Cygwin already installed, and last updated before June 2, 2011. An up-to-date guide will be available soon. For an up-to-date guide to an alternative libFTDI build, see Compiling OpenOCD for Windows 7 (LibFTDI).

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

Cygwin Changes May 2011

Until June 1, 2011, Cygwin is undergoing changes to improve its support for Windows cross-compilation. If you have downloaded or update Cygwin since May 1, 2011, you will need to make some changes to make the GCC C compiler support the -mno-cygwin flag. If you last updated Cygwin before May 1, 2011 or after June 1, 2011, you should skip this section.

That directory contains several symbolic links. Redirect them by typing the following. Hit Return after typing each line. The loop will not execute until you type the last line and hit Return. Be sure to include the trailing period at the end of the third line.

for f in *.o ; do
rm -f $f
ln -fs /usr/lib/mingw/$f .
done

If you do not do this, every time you try to compile with the -mno-cygwin flag you will see this error:

Type the above all one one line. Note that "../ftd2xx" is the path to your ftd2xx directory. You may need to change this argument if you extracted ftd2xx to a different location. You may use either a relative path, as above, or an absolute path, such as C:\cygwin\home\ftd2xx. The argument --with-ftd2xx-win32-zipdir should be used even on 64 bit Windows 7.

Finish compiling as follows:

make
make install

Preparing to Run OpenOCD

Navigate to C:\cygwin\home\openocd-0.4.0\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-0.4.0\src, but you may encounter problems with configuration files. For a more in-depth discussion of these issues, see OpenOCD Config File Paths. This guide recommends that you create a new 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.

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

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

Installing LibUSB Device Filters

If the configure command above halts with an error stating that it is unable to compile and run a test program, or if openocd.exe compiles successfully but cannot open the FTDI device, you may need to install a libusb Device Filter.