- Tue Oct 13, 2009 5:00 am
#82919
[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:
[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 allYou should be able use msysgit to download from GIT on Windows.git clone git://developer.intra2net.com/libftdi
o The latest sources for OpenOCD should also be downloaded from git and installed in C:\msys\src\openocd with:Code: Select allNote 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.git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
- o Download the libusb-win32_ft2232 x64 drivers from here and follow the instructions.
- 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 commandCode: Select allYou 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.make_all.bat
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 lineCode: Select alltoTARGETNAME = libusb0
Code: Select allo Edit C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\sources_drv and change the lineTARGETNAME = libusb0_x64
Code: Select alltoTARGETNAME = libusb0
Code: Select allo In the command prompt, navigate to C:\msys\src\libusb-win32-src-0.1.12.2\ddk_make\ and run the commandTARGETNAME = libusb0_x64
Code: Select allYou 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.make_all.bat
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
- 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 allThis will create the library interface for the LibUSBWin32 DLLdlltool.exe -d libusb0_x64.def -l /usr/local/lib/libusb.a
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 lineCode: Select allat 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.LIBRARY libusb0_x64.dll
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 allbecomesif ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x0403, 0x6001)) < 0)
Code: Select allYou 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")if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x9E88, 0x9E8F)) < 0)
o Issue the commandCode: Select allNote that if you want to debug OpenOCD/libftdi, you can add "-O0 -g -Wall" to CFLAGS./configure --build=x86_64-w64-mingw32 CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" LIBS="-lusb"
o You will get some warnings during configure, but you can ignore them. Then runCode: Select allLibftdi should compile without error, and will install in /usr/localmake make install
o [OPTIONAL] To test that libUSB is working, provided you modified find_all.c accordingly:Code: Select allTime to compile OpenOCD$ /usr/local/bin/find_all.exe Number of FTDI devices found: 1 Checking device: 0 Manufacturer: FTDI, Description: SheevaPlug JTAGKey FT2232D B
- o If you are using the latest GIT sources, you should not have to patch anything. Just run:Code: Select all(Once again, you can add a CFLAGS="-O0 -g -Wall" in there to compile with debug, so that you can use gdb)
./bootstrap ./configure --enable-maintainer-mode --build=x86_64-w64-mingw32 --enable-ft2232_libftdi CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" make
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.