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
2)
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
3)
Now we need the opencd source, change into /home/openocd and
use the following svn command:
Code: |
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
4)
Change into /home/openocd/trunk. Here we will build openocd
for a FT2232 interface now.
Type in the following commands:
Code: |
./bootstrap |
If you want to build a cygwin based openocd type now:
Code: |
./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:
Code: |
./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:
Code: |
./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:
Code: |
./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:
Code: |
make |
The executable "openocd.exe" will be created in the following folder:
/home/openocd/trunk/src
Even you can build the html docs with:
Code: |
make html |
The pdf of the documentation can be build with:
Code: |
make pdf |
but here you must have tex installed too.
Best regards,
Michael
Last edited by mifi on Sun Jun 21, 2009 4:40 am; edited 4 times in total
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/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
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:
Code: |
./configure |
This will configure the libftdi packages. After this you can build the libftdi library with the following command:
Code: |
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:
Code: |
make distclean |
But now use the following command to configure:
Code: |
./configure CC="gcc -mno-cygwin" |
After this you can build it with:
Code: |
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:
Code: |
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:
Code: |
./bootstrap |
Remember we want to build a libusb and libftdi FT2232 interface now, therefore use the following
configure command for cygwin based openocd:
Code: |
./configure --enable-maintainer-mode --disable-werror --disable-shared --enable-ft2232_libftdi |
but if you want to build a mingw based openocd type:
Code: |
./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:
Code: |
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.
Last edited by mifi on Wed Jul 08, 2009 9:17 am; edited 5 times in total