OpenOCD Compile on x64

From OpenPilot Project

Jump to: navigation, search

Contents

[edit] Introduction

This page describes the steps to build OpenOCD with the propriety FTDI drivers on x64 Windows to support FTDI based JTAG devices such as the FLOSS JTAG. It should also work for other devices which utilise the FTDI chipset however, the USB Device IDs will 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] FTDI 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 FT2232D chipset.

You will now want to extract the drivers zip file somewhere. To make paths simple in this document I am going to use C:\ as a place to extract all files, although this isn't best practice it makes things simple and furthermore if your goal is just to create a x64 OpenOCD, a lot of these directories are not needed once this process is completed.

[edit] Install

Extract the .zip file you downloaded from the FTDI site to C:\FTDI

File:FTDI.png

[edit] Driver Install

Before continuing you will want to remove all other drivers for your JTAG device.

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. 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, for now leave the c:\FTDI directory where it is and we can proceed to the OpenOCD section.

[edit] Toolchain

To compile OpenOCD, we are going to use the Mingw-w64 environment, this is a complete 64-bit native build environment for Windows.

It can be downloaded here.

The development environment does not need to be installed, it just needs to be extracted to C:\msys, any updates available on that page are just to be extract over the top of the files already in that directory. Once you have downloaded and extracted the build environment we can move on to downloading OpenOCD.

[edit] OpenOCD

At the time of writing this, the simplest approach is to use the latest OpenOCD from the GIT repository. An easy way to do this is just to download a snapshot from the OpenOCD Git web. On the righthand side of the commit table you will be able to download the latest snapshot as a zip file. It is expect however that from version 0.3.2 onwards OpenOCD should compile fine in a Mingw-w64 environment.

Once you have the OpenOCD source zip file, you need to extract it inside the Mingw-w64 tree. Create a directory under c:\msys called src, inside that directory extract the OpenOCD source, finally, take the C:\FTDI you created earlier and copy that to be under the OpenOCD source directory.

You should end up with something like the following:

File:FTDI2.png

[edit] FTDI lib & def files

In this archive, there are two files we need, a a .lib and .def. There are also some inf files there to support Olimex Device IDs that we do not need and should be ignored. These are required as files that come with the stock FTDI driver are in the wrong format for a MinGW environment, replace the files currently in the AMD64 directory with the ones from the archive.

[edit] Build

Everything should be ready to build now with one small exception, the ftd2xx64.dll needs to be available during the configure process for a small test that is performed. The simplest way to do this is to copy the ftd2xx64.dll back two levels from the FTDI/AMD64 directory to the src/openocd directory.

The next step is to enter the build environment, this is performed by running the WPG System64 (Bash shell) from the root of the C:\msys directory.

File:FTDI3.png


Within the build enviroment you need to change to the OpenOCD directory.

cd /src/openocd


If you have downloaded a snapshot or checked out OpenOCD from their git repository, you are going to have to run the bootstrap command, this is performed as below:

./bootstrap


Next the build is configured:

./configure --enable-maintainer-mode --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=ftdi --build=x86_64-w64-mingw32

Finally build and install OpenOCD:

make install

[edit] Installing

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:

C:\msys\local\bin\openocd.exe

Also the ftd2xx64.dll needs to be copied to the same location as the openocd.exe


And finally the complete directory from:

C:\msys\local\share\openocd\scripts


I keep my install under Program Files:

File:FTDI5.png


That's it, you should now have a working 64 bit OpenOCD using the FTDI supplied drivers. You can now delete the build environment and other misc files you used in the process.

Personal tools