Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@technobly
Last active January 25, 2023 14:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technobly/f2c14eaa7334db80849d45614250bdf0 to your computer and use it in GitHub Desktop.
Save technobly/f2c14eaa7334db80849d45614250bdf0 to your computer and use it in GitHub Desktop.
OpenOCD "configure: error: hidapi is required for the CMSIS-DAP" HIDAPI_LIBS

If you are trying to install OpenOCD with CMSIS-DAP support on Mac OS and having trouble, this Gist may be for you :)

This is the typical error if you specifically try to configure OpenOCD for CMSIS-DAP support

checking for HIDAPI... no
checking for HIDAPI... no
checking for HIDAPI... no
checking for LIBFTDI... no
checking for LIBFTDI... no
checking for LIBJAYLINK... no
configure: error: hidapi is required for the CMSIS-DAP Compliant Debugger

Build HIDAPI

$ git clone git://github.com/Dashlane/hidapi.git
$ cd hidapi
// NOTE: the following line may be omitted if you want to try a different version than I used
hidapi $ git checkout b00982f
hidapi $ ./bootstrap
hidapi $ ./configure --enable-static --disable-shared
hidapi $ make clean
hidapi $ make
hidapi $ export HIDAPI_LIBS="-L`pwd`/mac/.libs/ -lhidapi"
hidapi $ export PKG_CONFIG_PATH="`pwd`/pc/"
hidapi $ echo $HIDAPI_LIBS
<copy_this_path_for_later>   <--------------------------------- COPY!!!
hidapi $ echo $PKG_CONFIG_PATH
<copy_this_path_for_later>   <--------------------------------- COPY!!!

Install OpenOCD

Seems gross to copy the path directly, but trust me it doesn't work unless you do

Download https://sourceforge.net/projects/openocd/files/openocd/0.10.0/
$ cd openocd/openocd-0.10.0
openocd-0.10.0 $ HIDAPI_LIBS="<path_copied_before>" PKG_CONFIG_PATH="<path_copied_before>" ./configure --enable-cmsis-dap --disable-werror
e.g. openocd-0.10.0 $ HIDAPI_LIBS="-L/Users/brett/code/openocd/hidapi/mac/.libs/ -lhidapi" PKG_CONFIG_PATH="/Users/brett/code/openocd/hidapi/pc/" ./configure --enable-cmsis-dap --disable-werror
openocd-0.10.0 $ make clean
openocd-0.10.0 $ make install
// this should end with `done`

// check in a new tab
$ which openocd
/usr/local/bin/openocd
$ ls -l /usr/local/bin/openocd
< make sure it's today's date! >

Test a connection to your target adapter, and connect to a device

openocd-0.10.0 $ openocd -f interface/cmsis-dap.cfg
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : CMSIS-DAP: SWD  Supported
Error: CMSIS-DAP: JTAG not supported

openocd-0.10.0 $ openocd -f interface/cmsis-dap.cfg -f target/stm32f2x.cfg -c "\$_TARGETNAME configure -rtos FreeRTOS"
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : stm32f2x.cpu: hardware has 6 breakpoints, 4 watchpoints
@technobly
Copy link
Author

@jief666 thanks, changed this:

hidapi $ export PKG_CONFIG_PATH="`pwd`/mac/pc/"

to this:

hidapi $ export PKG_CONFIG_PATH="`pwd`/pc/"

@jief666
Copy link

jief666 commented Aug 1, 2022

Welcome.

@birnam
Copy link

birnam commented Jan 25, 2023

Suggest changing:

git clone git://github.com/Dashlane/hidapi.git

to the http endpoint:

git clone https://github.com/Dashlane/hidapi.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment