User Tools

Site Tools


Cross-compile OpenOCD on GNU/Linux for Windows


The following was done using OpenOCD 0.8.0 and Archlinux x86_64. The toolchain I used is mingw-w64. The target OS is Windows 7 32bits, but it should also work for 64bits versions.


You need a few packages. Some already exist in community or in AUR so:

yaourt -S mingw-w64-gcc mingw-w64-libusb mingw-w64-hidapi


Download this pkgbuild, make your package and install it: mingw-w64-libftdi.tar.gz

yaourt -U ./mingw-w64-libftdi*.tar.xz


Download this pkgbuild, make your package and install it: mingw-w64-libusb-compat.tar.gz

yaourt -U ./mingw-w64-libusb-compat*.tar.xz


Here's the trick, you need to remove the existing usb.h from mingw-w64-headers to be able to install mingw-w64-libusb-compat. There must be a better way to fix this conflict but I didn't have much time to investigate…

OpenOCD compilation

Get openocd-0.8.0.tar.bz2 from Sourceforge

  tar xavf openocd-0.8.0.tar.bz2
  cd openocd-0.8.0
  # Eventually apply the patches you want
  autoreconf -fiv
  mkdir build
  cd build
  HIDAPI_LIBS="-lhidapi" ../configure --build=i686-pc-linux-gnu --host=i686-w64-mingw32 --disable-shared
  make -j8

Get openocd.exe from build/src/

It will require the DLL files from /usr/i686-w64-mingw32/bin/

Running OpenOCD

Put the executable and the DLL in the same folder. Install WinUSB drivers for you device (maybe using Zadig). And you should be able to run OpenOCD with you usual config files.

/home/share/www/ · Last modified: 2019/12/25 15:40 (external edit)