How to build OpenOCD for windows

Hello,

here is a short tutorial how to build openocd for windows.

(Tested with SVN version 2348 of OpenOCD)

An other build instruction can be found at the piconomic

project here: http://piconomic.berlios.de/build_openocd.html

Install cygwin, but you need some additional tools from the

development package like:

  • autoconf: Wrapper scripts for autoconf commands

  • automake: Wrapper scripts for automake and aclocals

  • gcc: C compiler upgrade helper

  • libtool: A shared library generation tool

  • make: The GNU version og the ‘make’ utility

  • subversion: A version control system

In case you want to build openocd for the FT2232 interface,

you need the driver from FTDI too. Which can be found here:

http://www.ftdichip.com/Drivers/D2XX.htm

I assumed you have installed cygwin and downloaded the ftdi driver.

Extract the ftdi driver in the following directory /home/openocd.

This will create an extra folder inside /home/openocd called:

“CDM 2.04.06 WHQL Certified”

I do not like the spaces in the name here, please rename this

folder too “ftd2xx”:

/home/openocd/ftd2xx

Now we need the opencd source, change into /home/openocd and

use the following svn command:

svn checkout svn://svn.berlios.de/openocd/trunk trunk

Now the openocd source will be loaded and stored in the

folder “trunk”. You will now have two folders under /home/openocd like:

/home/openocd/trunk

/home/openocd/ftd2xx

Change into /home/openocd/trunk. Here we will build openocd

for a FT2232 interface now.

Type in the following commands:

./bootstrap

If you want to build a cygwin based openocd type now:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/openocd/ftd2xx

but if you want to build a mingw based openocd type:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/openocd/ftd2xx CC="gcc -mno-cygwin"

In case you want to create a debug version of OpenOCD you must add the following line to the configure command:

CFLAGS=“-O0 -g -Wall”

The new command will look like for a cygwin debug build:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/openocd/ftd2xx CFLAGS="-O0 -g -Wall"

and here the command for a mingw debug build:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/openocd/ftd2xx CC="gcc -mno-cygwin" CFLAGS="-O0 -g -Wall"

After the configure step OpenOCD can be build with the

following command:

make

The executable “openocd.exe” will be created in the following folder:

/home/openocd/trunk/src

Even you can build the html docs with:

make html

The pdf of the documentation can be build with:

make pdf

but here you must have tex installed too.

Best regards,

Michael

Hello,

here comes more information in case you want to build openocd for a interface which need libusb or libftdi.

(Tested with SVN version 2348 of OpenOCD)

First of all you must download libusb-win32 which can be found here:

http://sourceforge.net/projects/libusb-win32/files/

You need the libusb-win32-device-bin-0.1.12.2.tar.gz packages. Please extract this file into a temp

file. A new folder will be created called: libusb-win32-device-bin-0.1.12.2

Now copy the file libusb-win32-device-bin-0.1.12.2\include<B>usb.h

to the following directories:

c:\cygwin\usr\include

c:\cygwin\usr\include\mingw

Even you must copy the library libusb-win32-device-bin-0.1.12.2\lib\gcc<B>libusb.a

to the following directories:

c:\cygwin\lib

c:\cygwin\lib\mingw

Thanks to Spen for the mingw hint!

Now you are able to build a interface which need libusb, but now we want to prepare your cygwin

for libftdi too. Therefore download the libftdi source from this location:

http://www.intra2net.com/opensource/ftdi/

You need the libftdi-0.16.tar.gz file here. Download this file and extract it into the following folder

under cygwin /home/openocd. This will create a new folder like:

/home/openocd/libftdi-0.16

Now we want to build a cygwin and mingw version. First we will start with cygwin. Change in the new

folder libftdi-0.16 and use the following command:

./configure

This will configure the libftdi packages. After this you can build the libftdi library with the following command:

make

The make process will produce some errors, but don’t panic. The library should be created and you can find

the libftdi.a file in the following folder /home/openocd/libftdi-0.16/src/.libs

Copy the libftdi.a to the following directories:

c:\cygwin\lib

Now we want to build the mingw version. Therefore we must cleanup the libftdi folder first.

Change into the /home/openocd/libftdi folder and type the following command:

make distclean

But now use the following command to configure:

./configure CC="gcc -mno-cygwin"

After this you can build it with:

make

The same as before, the make process will produce some errors, but the library libftdi.a can be found in

the following folder /home/openocd/libftdi-0.16/src/.libs

Copy the libftdi.a to the following folder:

c:\cygwin\lib\mingw

Copy now the header file /home/openocd/libftdi-0.16/src/ftdi.h

to the following directories:

c:\cygwin\usr\include

c:\cygwin\usr\include\mingw

Thanks to Spen again who give me the hint for the separate cygwin/mingw build of libftdi.

Now you are able to build a interface which need libusb and libftdi. We will check this and build the FT2232

interface with libusb and libftdi. Therefore delete your trunk folder from the first post:

/home/openocd/trunk

and download a new fresh source again. Change into /home/openocd and use the following svn command:

svn checkout svn://svn.berlios.de/openocd/trunk trunk

The same procedure as before.

Change into /home/openocd/trunk. Here we will build openocd

for a FT2232 interface now. Type in the following commands:

./bootstrap

Remember we want to build a libusb and libftdi FT2232 interface now, therefore use the following

configure command for cygwin based openocd:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_libftdi

but if you want to build a mingw based openocd type:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_libftdi CC="gcc -mno-cygwin"

In case you want to create a debug version of OpenOCD you must add the following line to the configure command:

CFLAGS=“-O0 -g -Wall”

After the configure step OpenOCD can be build with the

following command:

make

The executable “openocd.exe” will be created in the following folder:

/home/openocd/trunk/src

Best regards,

Michael

PS: Post #1 and #2 was updated to support the SVN version 2348.

I tried to follow everything and get following mostly at the end

Make[3] No rule to make target ‘/home/openocd/ftd2xx/FTD2XX.lib’, needed by ‘openocd.exe’. Stop.

Any advise?

Hello Slava,

You must now copy the file “ftd2xx.lib” from

/home/openocd/ftd2xx/i386 or /home/openocd/ftd2xx/amd64

depending from your architecture into the following folder:

/home/openocd/ftd2xx

Have you done this?

Regards,

Michael

mifi:
Hello Slava,

You must now copy the file “ftd2xx.lib” from

/home/openocd/ftd2xx/i386 or /home/openocd/ftd2xx/amd64

depending from your architecture into the following folder:

/home/openocd/ftd2xx

Have you done this?

Yes - I did

C:\OpenOCD\ftd2xx\ftd2xx.lib is in place

Hello Slava,

C:\OpenOCD\ftd2xx\ftd2xx.lib is in place

NO, this is the wrong place!

Please copy it into your cygwin folder where you can use

no windows path to access it.

/home/openocd/ftd2xx

Regards,

Michael

mifi:
Hello Slava,

C:\OpenOCD\ftd2xx\ftd2xx.lib is in place

NO, this is the wrong place!

This helped - make finished - means my fault

I realized that directory for openocd should be exactely in /home/openocd

removed

Hello,

please do not post OpenOCD problems or errors here.

Create a new thread, this thread should be only for

build purpose of OpenOCD.

Best regards,

Michael

found in src\flash directory sources that samsung flash is supported and files for it. How can I include support of samsung flash?

found in flash.c list of supported drivers

flash_driver_t *flash_drivers =

{

&lpc2000_flash, &cfi_flash, &at91sam7_flash,

&str7x_flash, &str9x_flash, &stellaris_flash,

&str9xpec_flash, &stm32x_flash,

&tms470_flash, &ecosflash_flash,

&lpc288x_flash, &ocl_flash,

NULL,

};

saw in some conference instruction for old release

flash_driver_t *flash_drivers =

{

@@ -60,6 +61,7 @@

  • &s3c2410a_flash,

NULL,

};

But this is outdated and openocd has other function in current package - different files and funcs

How can I build with samsung flash support ? Or any support

for NAND flash not descirbed in documentation?

Hello Slava,

C:\OpenOCD\ftd2xx\ftd2xx.lib is in place

NO, this is the wrong place!

This helped - make finished - means my fault

I realized that directory for openocd should be exactely in /home/openocd

Please dear its a section only for make a open OCD so don’t disturb us. lol

My suggest is mifi that we describe our problem also in this thread than this tutorial will be complete. Which person face any problem post in this thread than this make a complete thread.

I have problem with build openocd revision 1297 with libftdi mingw based.

When I use command:

./configure --enable-ft2232_libftdi CC="gcc -mno-cygwin"

I get error:

checking Build & Link with libftdi...... configure: error: Cannot build & run test program using libftdi

I can build without any problems revision 717 mingw based and revision 1297 with Cygwin based.

Hello Bool,

take a look at the first post. I have added a new part to solve

the “Cannot build…” error.

The trick is to copy the ftd2xx.lib file inside the i386/amd64 folder to

libftd2xx.a

Best regards,

Michael

Mifi,

I am starting to build openOCD revision 2431 on my windows vista laptop.

I got the latest “free as in beer” version of the FTDI library

I even got svn to nicely download all the source into cygwin,

but beyond that the “./bootstap” and the “./congfigure” commands were bombing.

See attached .pdf to see how they bombed. I will send this to

who ever provides email that allows attachements.

Or see my post at:

https://lists.berlios.de/pipermail/open … 08984.html

Or .pdf at

https://lists.berlios.de/pipermail/open … t-0001.pdf

Thanks for any assistance,

Joe

I took another shot at attempting to compile my own version

of openOCD with ftd2xx. Both attemps on my work laptop (Vista)

and my home PC (XP) resulted in identical failure.

This is important and relates,

to a bunch of people who would like to be able to succesfully use

openOCD with ftd2xx, right now <<<<

viewtopic.php?t=16172[\url]

Fact of the matter is we can not get the compile to work and get stuck

trying to use the unix like commands “./bootstrap” and “./configure”

One nice and impressive thing is that subversion was able to

properly download all the source files for openOCD, so we are almost

there.

This is a plea for help.

Here is an excerpt from openOCDs own website, that indicates

they may admit that using cygwin is not easy. It would sure help

if someone would come to our rescue and prove to us that it can

be done:

============================================

Building OpenOCD from a repository requires a recent version of the GNU

autotools (autoconf >= 2.59 and automake >= 1.9). For building on

Windows, you have to use Cygwin. Make sure that your @env{PATH}

environment variable contains no other locations with Unix utils (like

UnxUtils) - these can’t handle the Cygwin paths, resulting in obscure

dependency errors. This was an observation gathered from the logs of

one user; please correct us if this is wrong.

Ref bottom of page here:

http://svn.berlios.de/svnroot/repos/ope … unk/README[\url]

===========================================

It seem this statement is saying “We have not figured it out yet, either”

So the community is still looking for more help.

I think there is someone out there who is more unix savy than us

that can get us un-stuck. Cygwin is unix, mostly.

Sincerely,

Joe

The issue I was having was largely do to McAffee virus protect

it looks like this needs to be disabled during $ ./bootstrap

This was on both computers where this problem was happening.

See also

https://lists.berlios.de/pipermail/open … 09079.html

Best regards,

Joe

Hi Michael,

can you please post clearly (again) where to copy the ftd2xx.lib → libftd2xx.a to?

I copied it to the /i386 and /amd64 directories, also as to /cygwin/lib and cygwin/lib/mingw.

I also copied th ftd2xx.h to usr/include and usr/include/mingw.

Still get the error:

checking for ftd2xx.lib exists (win32)… checking whether ftd2xx library works.

… configure: error: Cannot build & run test program using ftd2xx.lib

Maybe its not a good idea to do a compile in the configure script, where you don’t get any error or warning messages that could help you to find the problem.

I really did try for hours now! :frowning:

removed.

I’m curious, how do I compiler for the libftdi driver (–enable-ft2232_libftdi) - what files do I need to download, if any, aside from the SVN openocd sourcecode.

mifi,

Thanks for the very nice tutorial. I finally was able to complile OpenOCD for Windows with the ftd2xx drivers! I have a few comments based on my experience compiling OpenOCD using your tutorial.

  1. When installing Cygwin, in addition to the standard installation you need to have all of the following installed also:

-devel: autoconf, automake, gcc-core, libtool, subversion, make

-libs: ioperm, popt

  1. When running the ./configure scripts, you must have an the exact same ftd2xx device installed on your computer (by way of previously connecting a device and installing the exact version of the ftd2xx drivers you are compiling with). Otherwise the check and test for ftd2xx.lib will fail and you will get an error like this:
checking for ftd2xx.lib exists (win32)... checking whether ftd2xx library works. 
.. configure: error: Cannot build & run test program using ftd2xx.lib

Thanks again for this nice tutorial!