Compiling OpenOCD Win7 D2XX
Revision as of 04:47, 7 March 2012 by Jshankar (1 revision: Importing from edes32)
This guide will compile OpenOCD 0.5.0 on Windows 7 with the FTD2XX driver library, for use with the CEDT-USB-JTAG adapter. 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.
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.
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.
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)
- 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 CEDT-USB-JTAG Adapter
Libusb is a USB driver library you will need to communicate with the CEDT-USB-JTAG adapter. 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-220.127.116.11 from http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/18.104.22.168/libusb-win32-bin-22.214.171.124.zip/download. Open the zip archive and extract the contents to C:\cygwin\home.
Navigate to the folder \libusb-win32-bin-126.96.36.199\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-188.8.131.52\include. Copy the file usb.h to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.
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.
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 CEDT-USB-JTAG 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 cedt devices. There should be two of them.
- Right click the first cedt 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 cedt device.
A Note about Make Errors
With the latest version of Cygwin and its associated packages you may encounter errors with make commands. You may be able to fix these errors simply by powering through; if make gives an error, run make again. If it doesn't halt again in the same place, you can likely proceed without worry.
You may also encounter errors with the bootstrap command used to compile OpenOCD below. Try running bootstrap again. If it passes the point where it previously halted everything is most likely fine.
Download the OpenOCD 0.5.0 source from http://prdownload.berlios.de/openocd/openocd-0.5.0.zip and extract it to /home/USERNAME/openocd-0.5.0. This source doesn't include support for CEDT-SW-JTAG adapter.
The openocd-0.5.0-with-CEDT-SW-JTAG-support.patch patch provides support for CEDT-SW-JTAG adapter and config file for OpenOCD-0.5.0. Download the file openocd-0.5.0-with-CEDT-SW-JTAG-support.patch and Save the file to your new openocd-0.5.0 directory.
In the terminal window, navigate to the patch file and patch the source as follows:
cd ~/openocd-0.5.0 patch -p1 -i openocd-0.5.0-with-CEDT-SW-JTAG-support.patch
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-mingw32 make
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\openocd\tcl. 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:
board chip cpld cpu openocd.exe interface target test bitsbytes.tcl memory.tcl mmr_helpers.tcl readable.tcl