OpenOCD Compile on x86
From OpenPilot Project
Contents |
[edit] Introduction
This page describes the steps to build OpenOCD with the propriety FTDI drivers on x32 Windows to support the FLOSS JTAG. This technique should also work for other JTAG devices which utilise the FTDI chipset however, the USB Device IDs might have to be changed.
The main reason for doing this is the FTDI supplied drives are much faster than the current Open Source drivers on Windows however, binaries linked against the closed source FTDI drivers are not compatible with the GPL license that OpenOCD is released under and can not be distributed.
[edit] Toolchain
To start with you will need a toolchain to compile OpenOCD, in this tutorial we will use Cygwin as a way of getting the GNU toolchain under Windows. Cygwin uses a download wizard to obtain the various parts of the project we require.
- Download the Cygwin Download Wizard http://www.cygwin.com/setup.exe to a known folder like C:\cygwin. This is the folder we will use in this tutorial and as it can be completely removed after OpenOCD is built, it is recommended to use this folder.
[edit] Cygwin Download Wizard
Once the download wizard has downloaded, please run it and select the options as shown below.
This is not an error message, just a notification. Click OK to proceed.
[edit] Cygwin Component Selection
Please note that the installer will automatically select dependency packages (if required). The following packages must be explicitly selected to build OpenOCD:
- All>Archive>unzip: Info-ZIP decompression utility; for FTDI driver ZIP file
- All>Devel>autoconf: Wrapper scripts for autoconf commands
- All>Devel>automake: Wrapper scripts for automake and aclocals
- All>Devel>gcc: C compiler upgrade helper
- All>Devel>libtool: A shared library generation tool
- All>Devel>make: The GNU version of the 'make' utility
You can now proceed by clicking "Next >" and the Cygwin environment plus all required packages will be downloaded.
[edit] Start the Cygwin Environment
As conflict can occur when running Cygwin and other unix utilities are in the same path, e.g. when WinAVR is installed. It is recommended that "C:\cygwin\Cygwin.bat" be edited so that no other command line tools will be run accidentally:
@echo off C: chdir C:\cygwin\bin path ; bash --login -i
You can now start a Cygwin BASH shell session by either running C:\cygwin\Cygwin.bat or use the desktop icon:
[edit] The FTDI D2XX Driver
You will need to download the FTDI D2XX driver from FTDIChip.com. You'll want the .zip file version of the driver that supports the FT2232H chipset. At the time of writing the latest driver available is version CDM 2.06.00, this version will be used in this tutorial.
[edit] Extract the driver
$ unzip "CDM 2.06.00 WHQL Certified.zip"
Once this is done, it is benificial to rename the directory to something shorter to make things more managable:
$ mv "CDM 2.06.00 WHQL Certified.zip" ftd2xx
[edit] INF Files
The driver from the FTDI site has the USB identifiers set for the FTDI devices and not those from Olimex, so that these drives are recognised as the correct drivers for the Olimex devices you need to change a couple of areas in the .inf files. If you wish you can download the already changed versions of the INF files here, these should work with any version of the drivers from FTDI. There are also two two more of the files in this archive, these will not be used.
The changes below should enable the FTDI driver to support all Olimex JTAG devices including the Tiny-H that is the recommended JTAG of the OpenPilot project.
[edit] ftdiport.inf
In ftdiport.inf find the two sections FtdiHw and FtdiHw.NTamd64 (these will be next to each other) and replace them with the data below:
[FtdiHw]
%VID_15ba&PID_0003.DeviceDesc%=FtdiPort2232.NT,FTDIBUS\COMPORT&VID_15ba&PID_0003
%VID_15ba&PID_0004.DeviceDesc%=FtdiPort2232.NT,FTDIBUS\COMPORT&VID_15ba&PID_0004
%VID_15ba&PID_002a.DeviceDesc%=FtdiPort2232.NT,FTDIBUS\COMPORT&VID_15ba&PID_002a
%VID_15ba&PID_002b.DeviceDesc%=FtdiPort2232.NT,FTDIBUS\COMPORT&VID_15ba&PID_002b
[FtdiHw.NTamd64]
%VID_15ba&PID_0003.DeviceDesc%=FtdiPort2232.NTamd64,FTDIBUS\COMPORT&VID_15ba&PID_0003
%VID_15ba&PID_0004.DeviceDesc%=FtdiPort2232.NTamd64,FTDIBUS\COMPORT&VID_15ba&PID_0004
%VID_15ba&PID_002a.DeviceDesc%=FtdiPort2232.NTamd64,FTDIBUS\COMPORT&VID_15ba&PID_002a
%VID_15ba&PID_002b.DeviceDesc%=FtdiPort2232.NTamd64,FTDIBUS\COMPORT&VID_15ba&PID_002b
At the end of this file you will find a Strings section, again replace this with the code below:
[Strings]
FTDI="FTDI"
DESC="CDM Driver Package"
DriversDisk="FTDI USB Drivers Disk"
PortsClassName = "Ports (COM & LPT)"
VID_15ba&PID_0003.DeviceDesc="USB Serial Port"
VID_15ba&PID_0004.DeviceDesc="USB Serial Port"
VID_15ba&PID_002a.DeviceDesc="USB Serial Port"
VID_15ba&PID_002b.DeviceDesc="USB Serial Port"
SvcDesc="USB Serial Port Driver"
SerEnum.SvcDesc="Serenum Filter Driver"
[edit] ftdibus.inf
In ftdibus.inf we perform almost the same procedure, again find the two sections FtdiHw and FtdiHw.NTamd64 and replace them with the data below:
[FtdiHw]
%USB\VID_15ba&PID_0003&MI_00.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_0003&MI_00
%USB\VID_15ba&PID_0003&MI_01.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_0003&MI_01
%USB\VID_15ba&PID_0004&MI_00.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_0004&MI_00
%USB\VID_15ba&PID_0004&MI_01.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_0004&MI_01
%USB\VID_15ba&PID_002a&MI_00.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_002a&MI_00
%USB\VID_15ba&PID_002a&MI_01.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_002a&MI_01
%USB\VID_15ba&PID_002b&MI_00.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_002b&MI_00
%USB\VID_15ba&PID_002b&MI_01.DeviceDesc%=FtdiBus.NT,USB\VID_15ba&PID_002b&MI_01
[FtdiHw.NTamd64]
%USB\VID_15ba&PID_0003&MI_00.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_0003&MI_00
%USB\VID_15ba&PID_0003&MI_01.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_0003&MI_01
%USB\VID_15ba&PID_0004&MI_00.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_0004&MI_00
%USB\VID_15ba&PID_0004&MI_01.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_0004&MI_01
%USB\VID_15ba&PID_002a&MI_00.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_002a&MI_00
%USB\VID_15ba&PID_002a&MI_01.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_002a&MI_01
%USB\VID_15ba&PID_002b&MI_00.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_002b&MI_00
%USB\VID_15ba&PID_002b&MI_01.DeviceDesc%=FtdiBus.NTamd64,USB\VID_15ba&PID_002b&MI_01
And again file the Strings section and replace that with the code below:
[Strings]
Ftdi="FTDI"
DESC="CDM Driver Package"
DriversDisk="FTDI USB Drivers Disk"
USB\VID_15ba&PID_0003&MI_00.DeviceDesc="USB Serial Converter A"
USB\VID_15ba&PID_0003&MI_01.DeviceDesc="USB Serial Converter B"
USB\VID_15ba&PID_0004&MI_00.DeviceDesc="USB Serial Converter A"
USB\VID_15ba&PID_0004&MI_01.DeviceDesc="USB Serial Converter B"
USB\VID_15ba&PID_002a&MI_00.DeviceDesc="USB Serial Converter A"
USB\VID_15ba&PID_002a&MI_01.DeviceDesc="USB Serial Converter B"
USB\VID_15ba&PID_002b&MI_00.DeviceDesc="USB Serial Converter A"
USB\VID_15ba&PID_002b&MI_01.DeviceDesc="USB Serial Converter B"
SvcDesc="USB Serial Converter Driver"
ClassName="USB"
[edit] Install new FTDI Driver
Before continuing you will want to remove all other drivers for your JTAG device if you have installed any.
You should now plugin your USB JTAG device, Windows should not find drivers for it and should ask you for a location, if so, provide the directory of the driver files you downloaded that has the modified INF files, in our case this would be C:\cygwin\tmp\ftd2xx. If you are not asked to provide drivers, use the update driver feature in device manager. If all goes well you should now have your hardware recognised by Windows, some devices with multiple interfaces (composite devices) will need the driver install once for each interface they provide, for example the Olimex ARM-USB-TINY-H requires this driver 3 times.
[edit] Building OpenOCD
In this tutorial we use the latest stable OpenOCD release, at the time of writing this is OpenOCD version 0.3.1.
[edit] Download OpenOCD
You can get the latest source from the OpenOCD download page: http://sourceforge.net/projects/openocd/files/
Download the latest version to the folder C:\cygwin\tmp
[edit] Extract the source code
Start a Cygwin shell and change to the tmp directory (you can use TAB to auto-complete directories or filenames):
$ cd /tmp
No use tar to extract the archive you downloaded:
$ tar -zxvf openocd-0.3.1.tar.gz
The source code will now be extracted to C:\cygwin\tmp\openocd-0.3.1
You now want to change directory in to the source tree you have just extracted:
$ cd /tmp/openocd-0.3.1
[edit] Run the configure script
$ ./configure --enable-maintainer-mode --disable-werror --disable-shared
--enable-ft2232_ftd2xx
--with-ftd2xx-win32-zipdir=/tmp/ftd2xx CC="gcc -mno-cygwin"
A number of options are specified:
- --enable-maintainer-mode : enable make rules and dependencies not useful (and sometimes confusing) to the casual installer
- --disable-werror : do not treat warnings as errors
- --disable-shared : disable shared libraries
- --enable-ft2232_ftd2xx : enable building support for FT2232 based devices using the FTD2XX driver from ftdichip.com
- --with-ftd2xx-win32-zipdir=/tmp/ftd2xx : where (CYGWIN/MINGW) the zip file from ftdichip.com was unpacked
- CC="gcc -mno-cygwin" : specify that executable must not be dependant on Cygwin DLLs
This process will take anywhere from a few seconds to a few minutes. If successful, the script will create a "Makefile" and a "config.h" file.
[edit] Build the OpenOCD source
To build the OpenOCD source code, the make command is run:
$ make
Once the compile has completed, you should now have a working OpenOCD executable in C:\cygwin\tmp\openocd-0.3.1\src\openocd.exe.
[edit] Installing OpenOCD
Once the code is built, you'll want to copy the relevant files from the build environment to somewhere in your Windows install, the files you need are:
/tmp/openocd-0.3.1/src/openocd.exe
/tmp/ftd2xx/i386/ftd2xx.dll
And also the complete contents from the tcl directory:
/tmp/openocd-0.3.1/tcl/
A standard place to put these files would be in C:\Program Files\OpenOCD
The screenshot below shows my complete install:
[edit] System Path
You also need to add the OpenOCD path to you systems environment variables. You can achive this using the following method:
- Right clicking on "My Computer" > Properties > Advanced System Settings > Environment variables
- Add ";C:\Program Files\OpenOCD" to the very end of what is currently in the PATH setting.
Note: You might want to keep the /tmp/ftd2xx folder in case you need to re-install the drivers again.
[edit] Cleanup
You can now remove the Cygwin desktop icon and the C:\cygwin folder.













