Building OpenOCD with libfti/libusb for Windows 64

Open source ARM Debugger

Moderator: phalanx

Building OpenOCD with libfti/libusb for Windows 64

Postby el_nihilo » Tue Oct 13, 2009 5:00 am

[UPDATED - 2009.11.05 as the Win x64 patch has also been integrated in the latest GIT source for libftdi]
[UPDATED - 2009.10.20 as the MinGW-W64 patches have now been integrated in the latest GIT source for OpenOCD]

PREREQUISITES:
    o WPG System64 (MinGW x64) installed in C:\msys\
    o [Optional - Only needed if you want to recompile libusb-win32] libusb-win32-src-0.1.12.2.tar.gz extracted in C:\msys\src\libusb-win32-src-0.1.12.2\
    o The latest sources for libftdi should be downloaded from git (they contain important fixes for Win x64!) and installed in C:\msys\src\libftdi\
    If you have git installed you can retrieve the latest source with:
    Code: Select all
    git clone git://developer.intra2net.com/libftdi
    You should be able use msysgit to download from GIT on Windows.
    o The latest sources for OpenOCD should also be downloaded from git and installed in C:\msys\src\openocd with:
    Code: Select all
    git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
    Note that OpenOCD has recently been updated with patches to ensure successful compilation on MinGW, so if you are using the svn source or an archive version lower than 0.3.0, you will encounter issues. Using git is the only way to avoid these issues right now.

STEP 0 - OPTION A: Installing pre-compiled libusb-win32 drivers for Windows x64
    o Download the libusb-win32_ft2232 x64 drivers from here and follow the instructions.
STEP 0 - OPTION B: Building and installing the libusb-win32 drivers from scratch
    o Download and install Windows Driver Kit Version 7.0.0. Please note that this is a 700 MB ISO image, so it might take a while
    o (Building of 32 bit drivers) Open Windows Drivers Kits -> WDK 7600.16385.0 -> Build Environments -> Windows 7 -> x86 Free Build Environment (And yes, this will create Vista compatible drivers too!)
    o In the command prompt, navigate to C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\ and run the command
    Code: Select all
    make_all.bat
    You should now have a libusb0.sys and libusb0.dll in C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\. You can now close the "x86 Free Build Environment" command prompt window.
    o (Building of the 64 bit drivers) Open Windows Drivers Kits -> WDK 7600.16385.0 -> Build Environments -> Windows 7 -> x64 Free Build Environment
    o Rename libusb0.def and libusb0_drv.def in C:\msys\src2\libusb-win32-src-0.1.12.2\ to libusb0_x64.def libusb0_x64_drv.def respectively
    o Edit C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\sources_dll and change the line
    Code: Select all
    TARGETNAME = libusb0
    to
    Code: Select all
    TARGETNAME = libusb0_x64

    o Edit C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\sources_drv and change the line
    Code: Select all
    TARGETNAME = libusb0
    to
    Code: Select all
    TARGETNAME = libusb0_x64

    o In the command prompt, navigate to C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\ and run the command
    Code: Select all
    make_all.bat
    You should now have a libusb0_x64.sys and libusb0_x64.dll in C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\. You can now close the "x64 Free Build Environment" command prompt window.
    o Copy the following inf file to your C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\ directory. Edit it as appropriate according to your USB device (The LibUSB-Win32 drivers we built are not exclusive to FTDI USB devices)
    o Still in the ddk_make\ directory, create 2 empty files, named: "libusb_x64.cat" and "libusb.cat" (or edit the inf file to remove the .cat references)
    o Navigate to <your_WinDDK_install_dir>\7600.16385.0\bin\amd64\ and copy the files CertMgr.exe, MakeCert.exe and SignTool.exe to the C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\ directory
    o Follow the steps highlighted here to sign your drivers.
    o Remove any existing FTDI drivers, plug in your system, and install the libUSB drivers. One the drivers have been installed, you should have libusb0_x64.dll in C:\Windows\System32
STEP 1: Compiling libftdi
    o Make sure you have the LibUSB Win32 x64 driver installed, with libusb0_x64.dll in C:\Windows\System32\
    o Navigate to the directory where you have the libusb0_x64.def from the LibUSB-Win32 driver files and issue the command:
    Code: Select all
    dlltool.exe -d libusb0_x64.def -l /usr/local/lib/libusb.a
    This will create the library interface for the LibUSBWin32 DLL
    IMPORTANT NOTE: If you are using the libsub-win32 source def file (i.e. you used OPTION B for STEP 0), you need to add the line
    Code: Select all
    LIBRARY libusb0_x64.dll
    at the beginning of your def file. If not, you are likely to get the error "The application failed to start because "(null).dll" was not found" later on, as the DLL needs to be referenced in the lib file.
    o Copy the file usb.h from your libusb drivers to /usr/local/include (or C:\msys\local\include in Windows - create the directory if it doesn't exist)
    o [OPTIONAL] You might also want to check that libUSB is working using the libfti test programs (which is a wise thing to do before compiling OpenOCD), so before compiling libfti, you should retrieve the Vendor ID and Product ID of your USB device, and edit src/examples/find_all.c to update line #24.
    For instance, for the SheevaPlug dev kit:
    Code: Select all
        if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x0403, 0x6001)) < 0)
    becomes
    Code: Select all
        if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x9E88, 0x9E8F)) < 0)
    You can find the vendor ID & product ID in the Device Manager by going to: LibUSB-Win32 Devices -> <your device name> -> Properties -> Details -> Hardware ID. There you should see something like USB\VID_AAAA&PID_BBBB with AAAA being the vendor ID and BBBB the product ID. (For the SheevaPlug Dev Kit, the like is: "USB\VID_9E88&PID_9E8F&REV_0500&MI_00")
    o Issue the command
    Code: Select all
    ./configure --build=x86_64-w64-mingw32 CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" LIBS="-lusb"
    Note that if you want to debug OpenOCD/libftdi, you can add "-O0 -g -Wall" to CFLAGS
    o You will get some warnings during configure, but you can ignore them. Then run
    Code: Select all
    make
    make install
    Libftdi should compile without error, and will install in /usr/local
    o [OPTIONAL] To test that libUSB is working, provided you modified find_all.c accordingly:
    Code: Select all
    $ /usr/local/bin/find_all.exe
    Number of FTDI devices found: 1
    Checking device: 0
    Manufacturer: FTDI, Description: SheevaPlug JTAGKey FT2232D B
    Time to compile OpenOCD
STEP 2: Compiling OpenOCD
    o If you are using the latest GIT sources, you should not have to patch anything. Just run:
    Code: Select all
    ./bootstrap
    ./configure --enable-maintainer-mode --build=x86_64-w64-mingw32 --enable-ft2232_libftdi CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
    make
    (Once again, you can add a CFLAGS="-O0 -g -Wall" in there to compile with debug, so that you can use gdb)
    o Once the compilation has completed successfully, run make install. You should now be able to run a fully GPL compliant version of openocd on Windows 64 systems.
el_nihilo
 
Posts: 12
Joined: Thu Oct 08, 2009 8:23 am

Postby fjulian79 » Sat Dec 05, 2009 9:20 am

Hi !!

i was trying to use the drivers provided here with Windows 7 x64 and my amontec jtag key tiny and they did not work .. the installer fails during insalling the driver. I got the message that someting in the service installation sector is invalid (sorry for this crude translation, i have a german windows and thats what M$ call it *ggg*)

can you help me with this problem?

julian
fjulian79
 
Posts: 1
Joined: Sat Dec 05, 2009 9:11 am

Postby el_nihilo » Fri Dec 11, 2009 1:32 pm

Hi,

Have you checked that the Vendor ID and Product ID for your amontec jtag key tiny matched the ones reported by the Device Manager.

Also, unless I'm mistaken, I don't think you have used the right set of files for your driver installation (you need to download the libusb-win32_ft2232_drivers_x64.zip archive, and then run the various cmd file as administrator, as indicated in INSTALL.txt), because the original batch files I gave in the archive did not work with Windows 7.

I have now fixed them, but I don't really see how you could have installed the driver on Windows 7 with the previous archive, as you should have seen errors when trying to run the .cmd files.

Remember that, before you can install the driver on Windows x64, you must:

1. run the Windows_Enable_Test_Mode.cmd file as administrator and reboot your machine, if your machine is not already in Test Mode (you must see Test Mode displayed on your wallpaper before you attempt to install the drivers)

2. run the Sign_Drivers.cmd as administrator, before attempting to install the driver. This is because you cannot use the .sys files provided in the archive unless they are signed, and the original files from the zip are unsigned.

If you do just that, and have the proper VID and PID for your USB device in the .inf, then the driver installation should work.
el_nihilo
 
Posts: 12
Joined: Thu Oct 08, 2009 8:23 am

Postby seraulu1 » Sat Feb 06, 2010 5:45 am

thanks very good :)learn hypnosis free
seraulu1
 
Posts: 1
Joined: Sat Feb 06, 2010 5:41 am

Postby Nutter » Sat Feb 06, 2010 6:58 pm

seraulu1: You might want to see this topic for a pre-built OpenOCD and drivers that work with Win Vista/7 64 bit: http://forum.sparkfun.com/viewtopic.php?t=19358

As my reply in that other thread says, the instructions in this thread didn't quite work for driver installation.
Nutter
 
Posts: 48
Joined: Wed Mar 23, 2005 1:32 am
Location: Vancouver, BC

Postby flyingaligator1 » Fri Feb 12, 2010 6:29 pm

i have read all the posted msgs it helps me a lot with some of my problems.. thanks for the informations you have shared.. master resell rights
Work2
flyingaligator1
 
Posts: 1
Joined: Fri Feb 12, 2010 6:26 pm

Postby el_nihilo » Fri Feb 19, 2010 3:51 am

Nutter wrote:As my reply in that other thread says, the instructions in this thread didn't quite work for driver installation.

As per my reply in the other thread, I believe that Nutter's problem stem from the fact that the OpenOCD package didn't include the latest version of the scripts published in the driver files above.

The instructions from this thread should work for driver installation, but by all means, if they don't, please provide a detailed report of any error you see, so that I can attempt to address them.
el_nihilo
 
Posts: 12
Joined: Thu Oct 08, 2009 8:23 am

Re: Building OpenOCD with libfti/libusb for Windows 64

Postby jhonedon35 » Thu Sep 27, 2012 5:34 am

Pretty interesting stuff. I got answers to my unsolved questions. Thanks for this help.

Cheers
Jack the ripper Walk
jhonedon35
 
Posts: 1
Joined: Thu Sep 27, 2012 5:29 am


Return to OpenOCD

Who is online

Users browsing this forum: No registered users and 1 guest