How to build OpenOCD for windows

Open source ARM Debugger

Moderator: phalanx

Re: How to build OpenOCD for windows - It worked

Postby aukcspore » Fri Mar 12, 2010 2:38 am

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 . :)

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
 
Posts: 2
Joined: Wed Mar 10, 2010 7:11 pm

Re: How to build OpenOCD for windows

Postby bobbinz » Sat Mar 13, 2010 6:43 am

@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
bobbinz
 
Posts: 1
Joined: Sat Mar 13, 2010 6:40 am

Re: How to build OpenOCD for windows

Postby riemus123 » Mon Apr 26, 2010 6:04 am

Hi,
I downloaded the latest source from git.
Then I did the
Code: Select all
./bootstrap
, and
Code: Select all
./configure --enable-maintainer-mode
. But when I then run
Code: Select all
make
, the following error occurs:

Code: Select all
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?
riemus123
 
Posts: 1
Joined: Mon Apr 26, 2010 5:57 am

Re: How to build OpenOCD for windows

Postby Ales » Wed May 05, 2010 2:05 pm

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:
Code: Select all
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):
Code: Select all
./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.
Attachments
config.log
(78.53 KiB) Downloaded 133 times
Ales
 
Posts: 3
Joined: Wed May 05, 2010 12:18 pm

Re: How to build OpenOCD for windows

Postby Ales » Thu May 06, 2010 3:34 pm

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:
Ales
 
Posts: 3
Joined: Wed May 05, 2010 12:18 pm

Re: How to build OpenOCD for windows on Linux

Postby gibbon1 » Sun Jun 06, 2010 8:20 pm

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)
gibbon1
 
Posts: 6
Joined: Thu Oct 29, 2009 3:28 pm

Re: How to build OpenOCD for windows

Postby meixner » Wed Jun 30, 2010 7:49 am

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
meixner
 
Posts: 16
Joined: Wed Jun 30, 2010 7:15 am

Re: How to build OpenOCD for windows

Postby pieterc » Sat Aug 14, 2010 4:48 am

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
pieterc
 
Posts: 31
Joined: Thu Aug 30, 2007 9:29 am

Re: How to build OpenOCD for windows

Postby ernestw » Sat Dec 04, 2010 5:32 am

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
ernestw
 
Posts: 23
Joined: Mon Nov 22, 2010 7:52 pm

Re: How to build OpenOCD for windows

Postby ambok » Mon Dec 27, 2010 5:14 pm

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
ambok
 
Posts: 1
Joined: Mon Dec 27, 2010 5:11 pm

Re: How to build OpenOCD for windows

Postby DrDrago » Thu Apr 14, 2011 9:38 am

Hi
I can not compile the OpenOCD with the option 'CC="gcc -mno-cygwin"'. It says:
configure: error: unrecognized option: `-mno-cygwin'
I have read somewhere that this option is removed, but I did not found a guide how to overcome it.
If I try to build it for cygwin I have the following error:
Error: unable to open ftdi device: unable to claim usb device. Make sure the def
ault FTDI driver is not in use
in procedure 'init'
But the drivers are OK, since I can use the one compiled by Olimex. I am using ARM-USB-OCD (manufactured by Olimex).
Please, help me to compile the OpenOCD, since I would like to support it by writing a code for one Cortex (ARM) which is not supported yet.

Thank you in advance
Drago
DrDrago
 
Posts: 1
Joined: Thu Apr 14, 2011 9:24 am

Re: How to build OpenOCD for windows

Postby Mehdi6 » Mon Aug 08, 2011 11:41 pm

Hello,

here is a short tutorial how to build openocd for windows.
(Tested with SVN version 2348 of OpenOCD)

1)
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
see more:
http://blog.csdn.net/jordon_ah/article/details/4396866
Mehdi6
 
Posts: 1
Joined: Mon Aug 08, 2011 11:38 pm

Re: How to build OpenOCD for windows on Linux

Postby frpr » Sun Sep 18, 2011 7:25 am

Hello,
it is nice idea to compile under Ubuntu. Please Mr. "gibbon1" can you provide your command line args. for ./configure script for your example? Thank you.
frpr
 
Posts: 5
Joined: Tue Sep 06, 2011 12:54 pm

Re: How to build OpenOCD for windows

Postby caspencer » Thu Oct 13, 2011 5:28 pm

Here's a set of scripts I put together for cross-compiling OpenOCD for Windows via mingw32 on Debian:

openocd-mingw32-build-scripts

I'm by no means an expert at shell scripting or cross-compiling, but hopefully someone finds this useful.
caspencer
 
Posts: 1
Joined: Thu Oct 13, 2011 5:26 pm

Re: How to build OpenOCD for windows

Postby slavka012 » Thu Oct 25, 2012 2:21 pm

Good guide, I just would like to add this:

First, have tcl installed by the cygwin.

Second, after you start the bash, make sure PATH has nothing but /usr/bin in it. If you have some packages that might have tools with the same name in the PATH, it will give you all sorts of weird build errors. Once I removed all of those, the build went pretty smooth.
slavka012
 
Posts: 1
Joined: Thu Oct 25, 2012 11:42 am

PreviousNext

Return to OpenOCD

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron