How to build OpenOCD for windows

Open source ARM Debugger

Moderator: phalanx

Re: How to build OpenOCD for windows

Postby rgvandewalker » Mon Oct 29, 2012 5:19 pm

I built open OCD 0.6.1 by loading the .zip from sourceforge, and trying to follow the instructions on the first page.
./bootstrap didn't work for me, either.
I built it for windows using cygwin's MingW compiler, by installing MingW when I installed cygwin, and then using the following autoconf line:
./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/openocd/ftd2xx CC="i686-pc-mingw32-gcc -mno-cygwin"

I needed to add a flash algorithm, and it seems that to add things, one must change both the .am and .in files
in the directory where the file must live.
I still haven't tested the new code, but it's grossly alive; i.e. it complains about lacking a .cfg file, etc.
rgvandewalker
 
Posts: 2
Joined: Mon Oct 29, 2012 5:09 pm

Re: How to build OpenOCD for windows

Postby rgvandewalker » Tue Oct 30, 2012 4:20 pm

An update: I found that using cygwin to make windows code probably should cross compile.
The "CC" notation recommended on the first page to select a compiler is deprecated in the GNU automake documentation.
So, using cross compiling, with automake, the configure command to cross-compile to windows 32-bit is:

./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=/home/openocd/ftd2xx --build=i686-pc-cygwin --host=i686-pc-mingw32

A mistake in the above text: Do not edit *.in files; In a correctly-running automake, they are regenerated from the Makefile.am files.

My cygwin build environment installs the wrong version of aclocal.m4; before running make, I have to replace it with the one from the distribution files for openocd, and touch it so the make doesn't replace it. After that, the make complains but finishes.

I also found out more about the available options. I haven't tried them; YMMV.
The "ftd2xx" clauses, above get and use the proprietary but certified windows driver from FTDI, provider of the JTAG IC. Substituting "ftdi" into those commands with the 0.6.1 version of openocd is supposed to invoke the open-source asynchronous driver for the FTDI chip(s).
Also, it appears that the cygwin installer can install a MingW64 compiler that enables an option to cross-compile for 64-bit windows.
rgvandewalker
 
Posts: 2
Joined: Mon Oct 29, 2012 5:09 pm

Re: How to build OpenOCD for windows

Postby cmeyer » Tue Jan 22, 2013 4:46 pm

Has anyone had any success building OpenOCD 0.7.0 from the Git repo of late? I am trying to build it using the D2XX drivers and libusbx. I am trying to build from the Git repo because I need access to the latest TI ICDI on the LM4F devkit(s).

I have put the build script (as a Gist) at: https://gist.github.com/4599885

If I do not configure openocd with JLink and TI ICDI support enabled, everything works. But if I enable either JLink or TI ICDI support, the configuration and build seem to complete fine, but when I run openocd I get nothing on stdout, it just returns without doing anything.

This is the first time I have really tried to build OpenOCD cross-compiling under Cygwin for MinGW so it is quite possible I am not putting things where they belong.

I would appreciate any help.
cmeyer
 
Posts: 17
Joined: Tue Jan 22, 2013 4:41 pm

Re: How to build OpenOCD for windows

Postby ntfreak » Wed Jan 23, 2013 6:17 am

It can be a pain to setup the build on windows, I generally use linux to cross build.

I am presuming you have installed the various libs, eg. libusbx into the correct compiler directory?
Anyway can you show us the build log to show what is failing.

I do have a cygwin cross build setup on my work pc and for that i have switched to using mingw64-i686 (win32) and mingw64-x86_64 (win64) compilers.

Cheers
Spen
User avatar
ntfreak
 
Posts: 481
Joined: Sat Jun 17, 2006 9:42 am
Location: UK

Re: How to build OpenOCD for windows

Postby cmeyer » Wed Jan 23, 2013 6:47 am

Unfortunantly, the problem isn't the build. I can presumably build it just fine. I configure OpenOCD and then run 'make' and 'make install' and get no errors. I get an executable and as far as I can tell any libraries that it builds and requires. When I run the executable I don't see any output...no error message, no fault message, no unable to load library message, nothing but nothing. When I execute "openocd --version" I also get nothing.

Regarding installing the libraries to the correct location...that I do not know. As far as I can tell I have simply because during configuration everything is found, but it is possible that I haven't done something correctly. All of my steps (downloading the various libraries, extracting, copying them to required locations, configuration, build, etc) can be found in the gist I posted at https://gist.github.com/4599885 (it is the actual script I used to try and build OpenOCD).

I am using the MinGW environment that is found in the Cygwin packages:

gcc-mingw (20040810-1)
gcc-mingw-core (20050522-3)
gcc-mingw-g++ (20050522-3)
mingw-binutils (2.21-1)
mingw-gcc-core (4.5.2-1)
mingw-pthreads (20110507-1)
mingw-runtime (3.20-1)

Hmm...looks like you are using a different MinGW? I'll try using mingw64-i686 and see if that changes anything. I just assumed that the ones I installed where the generic version...the meta-packages, but maybe not?
cmeyer
 
Posts: 17
Joined: Tue Jan 22, 2013 4:41 pm

Re: How to build OpenOCD for windows

Postby cmeyer » Wed Jan 23, 2013 7:06 am

Well, just install i686-w64-mingw32 and I get the same thing (I updated the script in the gist to copy things to /usr/i686-w64-mingw32/sys-root/mingw).

If I was to cross-compile under linux for windows, would I follow the same steps simply specify a different '--build' option when configuring OpenOCD? I haven't found any good information that indicates HOW to install libusbx properly when using MinGW to cross-compile.
cmeyer
 
Posts: 17
Joined: Tue Jan 22, 2013 4:41 pm

Re: How to build OpenOCD for windows

Postby ntfreak » Wed Jan 23, 2013 7:58 am

Ah ok i misread your first post.

perhaps it is worth building OpenOCD with no adapters to check the tools are ok as no output sounds very strange.

Cheers
Spen
User avatar
ntfreak
 
Posts: 481
Joined: Sat Jun 17, 2006 9:42 am
Location: UK

Re: How to build OpenOCD for windows

Postby cmeyer » Wed Jan 23, 2013 8:20 am

I actually did build it without the '--enable-jlink' and '--enable-ti-icdi' options and it worked fine then.

I went ahead and installed MinGW on a Mint Linux virtual machine and took my same script, updated it to use the Mint/Ubuntu MinGW installation (i.e. simply changed the location that the libraries where getting copied to to /usr/i686-w64-mingw32/...) and things are now working. Copied over the build executable to my main Windows installation and it seems to be running...though I do now have another issue.

When trying to debug a Stellaris LM4F232 devkit from TI using OpenOCD, I can connect and reset the board and I can single instruction step through the boot process but I get mostly <UNDEFINED> instruction errors. I can the exact same board and debug it using a JLink using the JLink GDB server (same remote GDB client 'arm-none-eabi-gdb') and when I single instruction step and decode the instructions ('display/i $pc') I get correctly disassembled instructions.

Am I missing a configuration option?
cmeyer
 
Posts: 17
Joined: Tue Jan 22, 2013 4:41 pm

Re: How to build OpenOCD for windows

Postby ntfreak » Wed Jan 23, 2013 8:43 am

cmeyer wrote:I actually did build it without the '--enable-jlink' and '--enable-ti-icdi' options and it worked fine then.

I went ahead and installed MinGW on a Mint Linux virtual machine and took my same script, updated it to use the Mint/Ubuntu MinGW installation (i.e. simply changed the location that the libraries where getting copied to to /usr/i686-w64-mingw32/...) and things are now working. Copied over the build executable to my main Windows installation and it seems to be running...though I do now have another issue.


That's good news :)

cmeyer wrote:When trying to debug a Stellaris LM4F232 devkit from TI using OpenOCD, I can connect and reset the board and I can single instruction step through the boot process but I get mostly <UNDEFINED> instruction errors. I can the exact same board and debug it using a JLink using the JLink GDB server (same remote GDB client 'arm-none-eabi-gdb') and when I single instruction step and decode the instructions ('display/i $pc') I get correctly disassembled instructions.

Am I missing a configuration option?


Not so good, OpenOCD will only return the info requested by gdb - just a thought but try adding the following to your gdb init, it could be related to the memory map returned by OpenOCD.

Code: Select all
set mem inaccessible-by-default off


If this does not help perhaps better move to a new thread.

Cheers
Spen
User avatar
ntfreak
 
Posts: 481
Joined: Sat Jun 17, 2006 9:42 am
Location: UK

Re: How to build OpenOCD for windows

Postby cmeyer » Wed Jan 23, 2013 8:48 am

I get an error from OpenOCD regarding that syntax. Should it be "set mem-inaccessible-by-default off"?
cmeyer
 
Posts: 17
Joined: Tue Jan 22, 2013 4:41 pm

Re: How to build OpenOCD for windows

Postby ntfreak » Wed Jan 23, 2013 8:51 am

That needs to be in your gdb init, not OpenOCD

Spen
User avatar
ntfreak
 
Posts: 481
Joined: Sat Jun 17, 2006 9:42 am
Location: UK

Re: How to build OpenOCD for windows

Postby cmeyer » Wed Jan 23, 2013 9:02 am

Oops, sorry, missed that. I tried that and it didn't fix the issue. I have posted my question to a new thread now: viewtopic.php?f=18&t=34635
cmeyer
 
Posts: 17
Joined: Tue Jan 22, 2013 4:41 pm

Re: How to build OpenOCD for windows

Postby 88comsian » Mon Jul 08, 2013 10:15 am

Now copy the file libusb-win32-device-bin-0.1.12.2\include\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\libusb.a

to the following directories:

c:\cygwin\lib
c:\cygwin\lib\mingw


Hello,

I am trying to build OpenOCD for Olimex USB-TINY-H. I installed Cygwin, but the install directory doesn't contain C:\Cygwin\lib\mingw and C:\cygwin\include\mingw. So where do I copy the files. Please share ur views. Thanks
88comsian
 
Posts: 2
Joined: Thu Oct 21, 2010 8:45 am

Re: How to build OpenOCD for windows

Postby EmBlocks » Wed Jul 09, 2014 12:25 am

Hi,

I try to build openOCD on cygWin. The bootstrap and configure seems ok and the building goes quite well.

Till it comes by the linking of the Ulink.o. It gives an error of undefined roundf() but the -lm is on the command line. If i build a small program with roundf() it works.

Any idea how to solve this? thanks.

Edit:
Perhaps a minGW bug (http://sourceforge.net/p/mingw/bugs/2155/), right now I add the roundf to the ulink code.
I found systems which are testing the roundf() in the configure and are linking the roundf if necessary.

Update:
Everything is working now and build with cygWin. I had sbrk (memory allocation) errors of aclocal with Msys so I moved to cygWin. To make it build with the current cygWin installer (9 July 2014) you have to do some more steps then the tutorials are showing which can be found on the internet. You have to select some more packages (like pkg-config) which aren't apparently no longer installed by default. Symlink the aclocal and automake version 1.13 and apply the workaround as above.
EmBlocks
 
Posts: 5
Joined: Mon Dec 31, 2012 6:10 am

Re: How to build OpenOCD for windows

Postby Belerafon » Mon Nov 10, 2014 4:01 am

Hi. Latest experience of building OpenOCD-0.8.0 (commit 30203b3d8b8cf77986245dc1fd331697f36b5c05).
1. Clone OpenOCD repo: git://git.code.sf.net/p/openocd/code
2. Download mingw http://sourceforge.net/projects/mingw-w ... in32/sjlj/ This is online installer, I select compiller version 4.9.2 and architecture i686.
3. Download msys http://cznic.dl.sourceforge.net/project ... s-rev13.7z (online installer fail for me, this is end link to achcive).
4. Copy installed mingw to msys to "local" directory (this is easiest way : ), copy OpenOCD sources to msys\home\User.
5. Run msys console, go to source dir and run
Code: Select all
./bootstrap
and got something like
Code: Select all
User@MaxL ~/OpenOCD_src/code
$ ./bootstrap
+ aclocal
+ libtoolize --automake --copy
+ autoconf
+ autoheader
+ automake --gnu --add-missing --copy
Makefile.am:23: warning: wildcard $(srcdir: non-POSIX variable name
Makefile.am:23: (probably a GNU make extension)
Setting up submodules
Bootstrap complete. Quick build instructions:
./configure ....

Download libraries: http://citylan.dl.sourceforge.net/proje ... .14-win.7z and http://sourceforge.net/projects/libusb- ... t/download .
Take libusbx-1.0.14-win\MinGW32\static\libusb-1.0.a and put to msys+7za+wget+svn+git+mercurial+cvs-rev13\msys\local\lib
Take libusb-win32-bin-1.2.6.0\libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a and put to same location

Create a new file "libusb-1.0.pc" with next content:
Code: Select all
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libusb-1.0
Description: C API for USB device access from Linux userspace
Version: 1.0.18
Libs: -L${libdir} -lusb
Cflags: -I${includedir}

Put it to msys\local\lib\pkgconfig (create if not exists)
Do in console
Code: Select all
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Put header \libusbx-1.0.14-win\include\libusbx-1.0\libusb.h to msys\local\include
Run configure:
Code: Select all
LDFLAGS="-lusb-1.0" ./configure --prefix= --disable-shared --enable-aice --enable-jlink --enable-stlink

OpenOCD need only library libusb-1.0, but for for some reason it try to link old version libusb (not 1.0). LDFLAGS need to link proper version - libusb-1.0.
after configure have got
Code: Select all
OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices        yes (auto)
ST-Link JTAG Programmer                 yes
TI ICDI JTAG Programmer                 yes (auto)
Keil ULINK JTAG Programmer              yes (auto)
Altera USB-Blaster II Compatible        yes (auto)
Versaloon-Link JTAG Programmer          yes (auto)
Segger J-Link JTAG Programmer           yes
OSBDM (JTAG only) Programmer            yes (auto)
eStick/opendous JTAG Programmer         yes (auto)
Andes JTAG Programmer                   yes
USBProg JTAG Programmer                 no
Raisonance RLink JTAG Programmer        no
Olimex ARM-JTAG-EW Programmer           no
CMSIS-DAP Compliant Debugger            no

and run
Code: Select all
make

after make check openocd.exe in /home/User/OpenOCD_src/code/src
do
Code: Select all
make install

and collect new openocd:
openocd.exe you cat take in /home/User/OpenOCD_src/code/src, scripts and other in msys\share\openocd.
Belerafon
 
Posts: 1
Joined: Mon Nov 10, 2014 3:35 am

PreviousNext

Return to OpenOCD

Who is online

Users browsing this forum: No registered users and 4 guests