How to build OpenOCD for windows

async:
2) 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!

I’m getting this problem, but am having trouble installing ftd2xx to a device - is it compatible with the Olimex ARM-USB-OCD?

EDIT: ftd2xx or libftdi, heh. I’ve an Olimex ARM-USB-OCD or an Amontec Tiny

The Olimex OCD device is compatible with the FTD driver. It comes on the disk that ships with the Olimex OCD.

To be sure you have a clean driver instalation, FTD has a utility calledFTDClean on the page below. Run that to remove all the ftd drivers on your computer. Then reinstall your device with the latest FTD drivers from thier website. This will remove any confusion as to what driver you are actually using.

http://www.ftdichip.com/Resources/Utilities.htm

Hi everyone,

In case my post gets bumped down, I want to remind everyone that I have created a step by step (expanded) guide to build OpenOCD 0.2.0 for Windows using Cygwin (a Linux-like environment for Windows). It is linked against FTDI’s proprietary (non-GPL) FTD2XX Driver to support FT2232x based JTAG interfaces.

Visit:

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

Best regards,

Pieter

Hello Pieter,

is it possible to compile OpenOcd without Cygwin? I have just MinGW compiler. Or, does anybody have a Makefile for MinGW as “./configure” does not work ?

I currently use OpenOcd version built by Martin Thomas and there is no need to have Cygwin. There is no cygwin.dll near openocd.exe. So it must be somehow possible to build OpenOcd without Cygwin…

I use Cygwin to build OpenOCD, but the final binary is not dependent on Cygwin DLLs, because of the CC=“gcc -mno-cygwin” parameter, i.e. it is MingW in the end.

If you want to use MinGW, maybe you should look at the following post?

viewtopic.php?t=17598

Best regards,

Pieter

vaclavpe:
Hello Pieter,

is it possible to compile OpenOcd without Cygwin? I have just MinGW compiler. Or, does anybody have a Makefile for MinGW as “./configure” does not work ?

I currently use OpenOcd version built by Martin Thomas and there is no need to have Cygwin. There is no cygwin.dll near openocd.exe. So it must be somehow possible to build OpenOcd without Cygwin…

Hi,

I think if you use the “msys” package you will be able to run configure, I have used this in the past. Msys includes a shell interpreter and the utilities required to run configure scripts.

Update:

I have built a libusb OpenOCD using a Mingw/Msys build route, no Cygwin involved.

There were a few wrinkles in the configure scripts, since some of the packages have moved on. Importantly, “libusb-config” is no longer present in libusb32, I think it can be spoofed with a batch file that simply outputs the libusb version number (I used a DOS exe which loads libusb0.dll and gets the version in fact).

It’s also worth noting that the latest OpenOCD source is now in the GIT repository mastered at SourceForge; the SVN mirror at Berlios is no longer maintained. You either need a git client, or can download a snapshot of the tree as a tarball.

Hey Mifi,

Myself sandra and I am starting to build openOCD revision 2535 on my windows vista laptop.thanks for giving tips and coding here it will be easy for us.but after installation some

errors ar coming i dont understand why this are running. can you please help me.

stay connected.

Thanks…

I am having a problem with one of the first few steps

the step where i use the line

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

in the folder /home/openocd

response is

svn: No access allowed to this repository

Regards

mwoo769:

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

Hello,

the sources are now in a GIT repository. Check out this page:

http://openocd.git.sourceforge.net/git/ … ;a=summary

There you can download the sources as a snapshot or you can use GIT

Regards

Thank you for much for laying out the steps for building OpenOCD.

ONE BIG QUESTION: DOES THE USB (any FTDI based ) JTAG BE INSTALLED BEFORE I CAN BUILD OPENOCD?

I am using Cygwin (running under Window Vista) and installed it according to

http://piconomic.berlios.de/build_openo … ILD_PROCES

Following the steps in the first 2 post of this thread:

However I failed to build OpenOCD.

  1. ./bootstrap as mentioned does not work for me.

The screen shows:

bash: ./bootstrap: No such file or directory.

  1. ./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-parport --enable-parport_giveio --enable-ft2232_libftdi CC=“gcc -mno-cygwin”

after a long string of text output… window vista reported that conftest.exe failed or stop working.

Cygwin console output is:

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

Window Vista complained about conftest.exe program stop: see below:

Apparently according to the Windows Vista report: libusb0.dll is at fault. I did a directory search on my PC and found libsub0.dll in \libusb-win32-device-bin-0.1.12.2\bin I wonder if this is the problem and I need to install a FTDI device to cause this libusb0.dll to be installed and recognised by the Windows. If I don’t have a FTDI device installed can I still get configure to work by putting libusb0.dll into somewhere in the windows system directory. If this possible I hope someone can me point to the right directory.

Before this I tried building Openocd with ftd2xxx. which also ended in failure. But someone was saying that I need to have a real FTDI device installed before I can build openocd. I before I get a JTAG device I want to be sure I can compile the tools to use it. So I gave up this FTDI lib and go for the libsub + libftdi combo.

I hope somebody can help. I had been doing building thing for a quite awhile.

Regards

Window Vista failure details:

Problem signature:

Problem Event Name: APPCRASH

Application Name: conftest.exe

Application Version: 0.0.0.0

Application Timestamp: 4b99f097

Fault Module Name: libusb0.dll

Fault Module Version: 6.0.6002.18005

Fault Module Timestamp: 49e03821

Exception Code: c0000135

Exception Offset: 00009eed

OS Version: 6.0.6002.2.2.0.768.3

Locale ID: 18441

Additional Information 1: 9d13

Additional Information 2: 1abee00edb3fc1158f9ad6f44f0f6be8

Additional Information 3: 9d13

Additional Information 4: 1abee00edb3fc1158f9ad6f44f0f6be8

Hi all,

I found the solution to the problem I encountered and reported in the previous post.

The steps here are for compiling openocd on PC without the USB driver/JTAG deive installed.

  1. ./bootstrap did not work and is ok.

  2. ./configure will work only if I do the following.

If you are using the libusb+libftdi combo, for this to work (./configure) you need to be sure that libusb0.dll is in the same directory as configure IF YOU DON’T NEED TO HAVE THE REAL USB DEVICE driver installed. So I copied libusb0.dll from

/home/openocd/libusb-win32-device-bin-0.1.12.2/bin/libusb0.dll to

/home/openocd/openocd-0.4.0/ in my case.

Then you run the ./configure … as in mifi post.

We can do the same for the FTDI supplied driver. The key point is the ftd2xx.dll as above. In this case I copied ftd2xx.dll from

/home/openocd/ftd2xx/i386/ftd2xx.dll to

/home/openocd/openocd-0.4.0/

(Note that I unzipped a fresh set of files to /openocd-0.4.0/ for the second run to build openocd for ftd2xx.dll after I built openocd for libusb+libftdi in the first run.)

I still can’t get bootstrap to work. I hope someone can throw some light on this. Anyway, it does not really matter as I managed to build openocd.exe . :slight_smile:

I hope mifi can update his 2 excellent post to include those mentioned steps for those of us who don’t have the REAL USB device installed to able to compile.

Thank you very much.

Best regards,

aukcspore.

@aukcspore:

Try converting the bootstrap file to Unix format (use Notepad++ for example) then try running it again. I had similar problem until I did this. I believe there’s a way to tell Cygwin to use Windows format, but I didn’t look into this.

BBz

Hi,

I downloaded the latest source from git.

Then I did the ./bootstrap, and ./configure --enable-maintainer-mode. But when I then run ```
make


~~~
make[6]: Entering directory `/home/openocd/openocd/src/jtag'
/bin/sh ../../libtool --tag=CC   --mode=link gcc -std=gnu99  -g -O2 -Wall -Wstrict-prototypes -Wformat-security -Wextra
-Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls   -o libjtag.la  adapter.lo core.lo interface.l
o interfaces.lo tcl.lo   commands.lo ../../src/jtag/drivers/libocdjtagdrivers.la -lioperm
libtool: link: rm -fr  .libs/libjtag.lax
libtool: link: (cd .libs/libjtag.lax/libocdjtagdrivers.a && ar x "/home/openocd/openocd/src/jtag/../../src/jtag/
drivers/.libs/libocdjtagdrivers.a")
libtool: link: object name conflicts in archive: .libs/libjtag.lax/libocdjtagdrivers.a//home/openocd/openocd/src
/jtag/../../src/jtag/drivers/.libs/libocdjtagdrivers.a
make[6]: *** [libjtag.la] Error 1
make[6]: Leaving directory `/home/openocd/openocd/src/jtag'
~~~

My machine is Win XP and it is Cygwing that I am using.

Any pointers?

Hello,

I tried to compile OpenOCD for win32 with FTDI’s drivers, but I stuck on error with ‘undefined references’ to functions from usb.h. This is output from terminal:

libtool: link: i586-mingw32msvc-ranlib .libs/libopenocd.a
libtool: link: rm -fr .libs/libopenocd.lax .libs/libopenocd.lax
libtool: link: ( cd ".libs" && rm -f "libopenocd.la" && ln -s "../libopenocd.la" "libopenocd.la" )
i586-mingw32msvc-gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -I../src -I../src   -mno-cygwin -D__USE_MINGW_ANSI_STDIO -I/home/ales/comp/openocd/ftdi2xx -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
/bin/bash ../libtool --tag=CC   --mode=link i586-mingw32msvc-gcc -std=gnu99  -mno-cygwin -D__USE_MINGW_ANSI_STDIO -I/home/ales/comp/openocd/ftdi2xx -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror  -L/home/ales/comp/openocd/ftdi2xx/i386 -o openocd.exe main.o libopenocd.la -lftd2xx
libtool: link: i586-mingw32msvc-gcc -std=gnu99 -mno-cygwin -D__USE_MINGW_ANSI_STDIO -I/home/ales/comp/openocd/ftdi2xx -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -o openocd.exe main.o  -L/home/ales/comp/openocd/ftdi2xx/i386 ./.libs/libopenocd.a -lws2_32 -lftd2xx
./.libs/libopenocd.a(arm-jtag-ew.o):arm-jtag-ew.c:(.text+0x111c): undefined reference to `_usb_init'
./.libs/libopenocd.a(arm-jtag-ew.o):arm-jtag-ew.c:(.text+0x117e): undefined reference to `_usb_claim_interface'
./.libs/libopenocd.a(arm-jtag-ew.o):arm-jtag-ew.c:(.text+0x11a0): undefined reference to `_usb_close'
./.libs/libopenocd.a(arm-jtag-ew.o):arm-jtag-ew.c:(.text+0x12bc): undefined reference to `_usb_bulk_write'
./.libs/libopenocd.a(arm-jtag-ew.o):arm-jtag-ew.c:(.text+0x12f4): undefined reference to `_usb_bulk_read'
./.libs/libopenocd.a(usb_common.o):usb_common.c:(.text+0x82): undefined reference to `_usb_find_busses'
./.libs/libopenocd.a(usb_common.o):usb_common.c:(.text+0x87): undefined reference to `_usb_find_devices'
./.libs/libopenocd.a(usb_common.o):usb_common.c:(.text+0x8c): undefined reference to `_usb_get_busses'
./.libs/libopenocd.a(usb_common.o):usb_common.c:(.text+0xc8): undefined reference to `_usb_open'
collect2: ld returned 1 exit status
make[4]: *** [openocd.exe] Error 1
make[4]: Leaving directory `/home/ales/comp/openocd/oocd/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/ales/comp/openocd/oocd/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/ales/comp/openocd/oocd/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ales/comp/openocd/oocd'
make: *** [all] Error 2
ales@pc1:~/comp/openocd/oocd$

I compiled at linux Ubuntu (this is my first experience with linux) and with following .configure options (mostly collected somewhere on the net and readme’s):

./configure --build=i686-pc-linux --host=i586-mingw32msvc --enable-maintainer-mode --disable-shared --enable-arm-jtag-ew --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/ales/comp/openocd/ftdi2xx CC=i586-mingw32msvc-gcc CFLAGS=-mno-cygwin CPP=i586-mingw32msvc-cpp

usb.h is placed in /usr/include and /usr/i586-mingw32msvc/include

usblib.a is placed in /usr/lib and /usr/i586-mingw32msvc/lib

If it can be helpful, config.log is in attachment.

Please, can anybody tell me what is wrong or how to fix it? I tried to copy usb.h and usblib.a almost everywhere, but it seems it’s not the problem. If I remove --enable-arm-jtag-ew option, I will get openocd.exe, but it’s of course useless, because it doesn’t have any jtag functionality.

Thanks a lot for any advice.

Ales.

Previous post SOLVED

I’m idiot. I didn’t try the --enabe-usbprog because I was thinking that’s not my case (like device named Usbprog) and --enable-arm-jtag-ew (option for USB debugger by Olimex) involve all the needed USB fuctionality, but it’s only support for a particular programmer/debugger, not the interface (USB, parallel). :roll:

As someone who dislikes cygwin because it tends to cause issues with my other more native development tools, is anyone interested in building OpenOCD for windows on ubuntu + mingw cross compiler? Instead of mucking around with cygwin on windows, muck around on ubuntu and use mingw to cross compile openocd for windows?

This is the route that I’m trying to take at the moment. AKA let Windows be Windows and Linux be Linux and let the cross compiler do the dirty work.

Edit: Totally appears to work.

The MinGW i386-mingw-gcc cross compiler builds without incident on ubuntu 8.04 from here

http://sourceforge.net/projects/mingw/files/

You do need to get the libusb.a and usb.h files from

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

And because (I think) I’m using an FTDI based device the non-open source drives from here

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

Grab the open ocd sources from

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

I extracted the ftdi usb drivers to openocd-0.4.0/ftd2xx/

And placed usb.h in openocd-0.4.0/ftd2xx

And libusb.a in openocd-0.4.0/ftd2xx/i386 (This seems to be in the linkers search path)

Hello!

In case someone wants to compile openocd 0.4.0 using Mingw/MSys along the driver from FTDI. This is what worked for me:

unzip openocd-0.4.0.zip

mkdir CDM20602

cd CDM20602

unzip …/CDM20602.zip

cd …

mkdir build

cd build

…/openocd-0.4.0/configure --prefix=/c/openocd --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=…/CDM20602

make

make install

  • Matthias Meixner

I have updated my step-by-step guide “How to build OpenOCD with FTDI’s CDM driver for Windows” and it is now hosted at:

http://piconomic.co.za/fwlib/_b_u_i_l_d … o_c_d.html

Please update your links.

Share and enjoy!

Pieter

To All,

Just beware with Vista and Windows 7. It seems these OS do not work well with some new hardware drivers.

Also the FTDI drivers - while they are certified you must make sure that they have the right VID and PID to match whatever debug link hardware you have,

I am using an Olimex ARM-JTAG-Tiny-H link. The VID is 15BA and the PID can be 002A or 0003 or 0004.

So you need to get the FTDI driver which has the correct VID and PID.

I am in the process of moving this project onto a Win-32 OS because of these issues.

Ernest

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

cnx nano premium