How to build OpenOCD for windows

Another functional cross build for Windows (running on Debian) is available from the GNU ARM Eclipse OpenOCD pages:

http://gnuarmeclipse.livius.net/wiki/Ho … ws_OpenOCD

All required libraries (borrowed from the PICUSB project) are included in the package.

There are are also pages detailing the OS X and Debian native builds:

http://gnuarmeclipse.livius.net/wiki/Main_Page#OpenOCD

Hey, I have built OpenOCD under Windows using MSYS2. It is quite easy considered that I am very n00b. :mrgreen:

Someone has ever used MSYS2 for this purpose?

You can build OpenOCD for Windows natively with either MinGW-w64/MSYS

or Cygwin (plain MinGW might work with --disable-werror but is not

recommended as it doesn’t provide enough C99 compatibility).

Alternatively, one can cross-compile it using MinGW-w64 on a *nix

host. See README for the generic instructions.

Also, the MSYS2 project provides both ready-made binaries and an easy

way to self-compile from their software repository out of the box.

Native MinGW-w64/MSYS compilation


As MSYS doesn’t come with pkg-config pre-installed, you need to add it

manually. The easiest way to do that is to download pkg-config-lite

from:

http://sourceforge.net/projects/pkgconfiglite/

Then simply unzip the archive to the root directory of your MinGW-w64

installation.

USB adapters


For the adapters that use a HID-based protocol, e.g. CMSIS-DAP, you do

not need to perform any additional configuration.

For all the others you usually need to have WinUSB.sys (or

libusbK.sys) driver installed. Some vendor software (e.g. for

ST-LINKv2) does it on its own. For the other cases the easiest way to

assign WinUSB to a device is to use the latest Zadig installer:

http://zadig.akeo.ie

When using a composite USB device, it’s often necessary to assign

WinUSB.sys to the composite parent instead of the specific

interface. To do that one needs to activate an advanced option in the

Zadig installer.

For the old drivers that use libusb-0.1 API you might need to link

against libusb-win32 headers and install the corresponding driver with

Zadig.

If you need to use the same adapter with other applications that may

require another driver, a solution for Windows Vista and above is to

activate the IgnoreHWSerNum registry setting for the USB device.

That setting forces Windows to associate the driver per port instead of

per serial number, the same behaviour as when the device does not contain

a serial number. So different drivers can be installed for the adapter on

different ports and you just need to plug the adapter into the correct

port depending on which application to use.

For more information, see:

http://msdn.microsoft.com/en-us/library … s.85).aspx

http://www.ftdichip.com/Support/Knowled … number.htm

I don’t know enough about openocd, but it looks like that server start is failing:

1: (695) LaunchOptions DebugServer=‘C:\Program Files\GNU ARM Eclipse\OpenOCD\0.10.0-20170609\bin\openocd.exe’

1: (695) LaunchOptions DebugServerArgs=‘-s C:\Program Files\GNU ARM Eclipse\OpenOCD\0.10.0-20170609\share\openocd\scripts -f board/st_nucleo_f4.cfg -f interface/stlink-v2-1.cfg -c init -c “reset init”’

1: (695) LaunchOptions ServerStarted=‘target halted due to debug-request, current mode: Thread’

Hi @mifi ,

Thanks for the tutorial!

I was able to create an openocd image with ft2xx but when I try to execute the command below bash asks me to install libusb driver

iburange@LT-4351 MINGW64 ~/openocd/openocd-code/openocd/src
$ ./openocd.exe -f interface/ftdi/ft232h-module-swd.cfg -f target/stm32l4x.cfg -c init
Open On-Chip Debugger 0.12.0+dev-02241-g3fd975941 (2025-10-13-20:58)
Licensed under GNU GPL v2
For bug reports, read

Info : FTDI SWD mode enabled
Error: libusb_claim_interface() failed with LIBUSB_ERROR_NOT_SUPPORTED
Error: unable to open ftdi device with description ‘', serial '’ at bus location ‘*’

Is there a way to make openocd working without changing the driver to libusb.

Thanks in Advance!