Compile OpenOCD for Windows

From DP

Revision as of 06:47, 21 January 2011 by Jamz (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation , search

Contents

Introduction

We are going to compile OpenOCD to run under windows environment using a cross compiler hosted on Linux/Debian or Cygwin

Please see this link on how to create a cross-compiler environment for your OS

Requirements

To compile OpenOCD to run in a windows environment, you need a cross compiler on Cygwin or linux

This documentation is based on a Debian build but a few modification will enable you to compile on your linux flavor. Cygwin, which runs on windows will also be able to create an executable that run under windows, outside of the Cygwin environment.

You also need the library from http://www.ftdichip.com/Drivers/D2XX.htm if you use ftdi chips or the more open source from Libftdi from http://www.intra2net.com/en/developer/libftdi/download.php

Downloading OpenOCD

You can download OpenOCD from the git repository:

git://openocd.git.sourceforge.net/gitroot/openocd/openocd

You may use the command line version for Git:

mkdir openocd cd openocd git init openocd git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

and update it with:

git pull

NOTE: You need to run ./bootstrap to create 'configure' before you can run ./configure --enable-maintainer-mode with the corresponding flag,

or you can download it from:

http://sourceforge.net/projects/openocd/

Unzip to a directory and chdir.


test compile/run in native mode with

./configure

./make

./make install

  • run it

cd src/ ./openocd

Cross compiling OpenOCD for Windows

The most basic command and parameter to cross-compile OpenOCD is:

./configure --build=i686-pc-linux-gnu --host=i586-mingw32msvc 

the parameter after the flag --host is cross-compiler dependent:

On some cross-compilers you need to specify --host=i686-w64-mingw32 if you build yours from

http://mingw-w64.sourceforge.net/

The --host flag will tell ./configure to look at the cross-compile bin directory where the files with i686-w64-mingw32-*.exe is located. This bin directory should be the first path in your PATH variable.

For FTD2xx

 ./configure --enable-maintainer-mode --host=i586-mingw32msvc  --disable-werror   --with-ftd2xx-win32-zipdir="/home/username/CDM20808"  --with-ftd2xx-lib=static  --enable-ft2232_ftd2xx   --disable-at91rm9200  

Other configure flags and parameters

NOTE: Taken from the readme file of OpenOCD

 --enable-maintainer-mode   Enable make rules and dependencies not useful (and sometimes confusing) to the casual installer
                            NOTE: This option is *required* for GIT builds! It should *not* be used to build a release.  
 --enable-dummy             Enable building the dummy JTAG port driver
 --enable-ft2232_libftdi    Enable building support for FT2232 based devices using the libftdi driver, opensource alternate of FTD2XX
 --enable-ft2232_ftd2xx     Enable building support for FT2232 based devices  using the FTD2XX driver from ftdichip.com
 --enable-gw16012           Enable building support for the Gateworks GW16012 JTAG Programmer
 --enable-parport           Enable building the pc parallel port driver
 --disable-parport-ppdev    Disable use of ppdev (/dev/parportN) for parport (for x86 only)
 --enable-parport-giveio    Enable use of giveio for parport (for CygWin only)
 --enable-presto_libftdi    Enable building support for ASIX Presto Programmer using the libftdi driver
 --enable-presto_ftd2xx     Enable building support for ASIX Presto Programmer using the FTD2XX driver
 --enable-amtjtagaccel      Enable building the Amontec JTAG-Accelerator driver
 --enable-arm-jtag-ew       Enable building support for the Olimex ARM-JTAG-EW Programmer
 --enable-jlink             Enable building support for the Segger J-Link JTAG Programmer
 --enable-rlink             Enable building support for the Raisonance RLink JTAG Programmer
 --enable-usbprog           Enable building support for the usbprog JTAG Programmer
 --enable-vsllink           Enable building support for the Versaloon-Link JTAG Programmer
 --enable-oocd_trace        Enable building support for the OpenOCD+trace ETM capture device
 --enable-ep93xx            Enable building support for EP93xx based SBCs
 --enable-at91rm9200        Enable building support for AT91RM9200 based SBCs
 --enable-ecosboard         Enable building support for eCos based JTAG debugger
 --enable-zy1000            Enable ZY1000 interface
 --enable-minidriver-dummy  Enable the dummy minidriver.
 --enable-ioutil            Enable ioutil functions - useful for standalone
                            OpenOCD implementations
 --enable-httpd             Enable builtin httpd server - useful for standalone
                            OpenOCD implementations
 --disable-doxygen-html     Disable building Doxygen manual as HTML.
 --enable-doxygen-pdf       Enable building Doxygen manual as PDF.

Testing and running on Windows

Simply copy the EXE file and the corresponding libraries in a windows environment.

Win7openocd.png Running on Win7 console

Some tricks, Notes and troubleshooting

In case the compilation failed, always look at the config.log file. Verify that you have a working cross-compile environment, the cross-compiler's path must be the first one in the PATH variable, and that all the necessary libraries are called in the right path.

There are many different builds for a cross-compiler. The '--host' flag should be modified accordingly. In the latest cygwin, the -mno-cygwin does not work or ignored. Use the '--host' flag instead with the right parameter, e.g. i686-w64-mingw32 while on linux or debian, it could be 'i586-mingw32msvc', and that's depend on where you got your cross-compiler build.

To troubleshoot, first try to compile it without the libraries (ftd2xx or libftdi) to see if it pass through the compilation process then add the flags one at a time.

Read the 'Readme' or 'Readme.win32' file included in the repository. It has a lot of information that can lead to a successfull cross-compilation.

If you are using FTDI chips, be sure to use the libraries for windows.

References and Resources

http://mingw-w64.sourceforge.net/

http://wiki.njh.eu/Cross_Compiling_for_Win32#Debian_cross_compiling_for_w32-i386

http://mingw-cross-env.nongnu.org/#tutorial

http://cs.nyu.edu/~yap/prog/cygwin/FAQs.html