Skip to content

Instantly share code, notes, and snippets.

@technobly
Last active Mar 16, 2021
Embed
What would you like to do?
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`/mac/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
@frostfire45

This comment has been minimized.

Copy link

@frostfire45 frostfire45 commented Jul 9, 2020

Hey bud that helped out greatly. I ended up needing to do a lot of code debugging, due to fall throughs etc. I am going to post the changes that I made to the openOCD files.

@citizenfish

This comment has been minimized.

Copy link

@citizenfish citizenfish commented Mar 13, 2021

Hi thanks for this which helped me a lot. You may want to edit the instructions to work with current versions of openocd:-

Change the path here:-

 export PKG_CONFIG_PATH="$HIDAPI_DIR/mac/pc/"

To:

 export PKG_CONFIG_PATH="$HIDAPI_DIR/pc/"

I used the following as $HIDAPI_DIR was not defined:-

export HIDAPI_LIBS="-L`pwd`/mac/.libs -lhidapi"
export PKG_CONFIG_PATH="`pwd`/pc"
@technobly

This comment has been minimized.

Copy link
Owner Author

@technobly technobly commented Mar 16, 2021

Thanks @citizenfish! I've updated the instructions with your changes. I don't recall how HIDAPI_DIR was previously set, but your method will work fine.

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