Closed renaudcerrato closed 6 years ago
BTW, I tried adding cmsis_dap_vid_pid 0x03eb 0x2111
to the board script with no change.
OpenOCD 0.9.0 is able to detect the CMSIS-DAP interface, but not the latest version?
unfortunately, personally I'm not using openocd at all, and I have no idea when interfaces are added/removed, and how to use them.
the script to build the openocd binaries is available at https://github.com/gnuarmeclipse/build-scripts/blob/master/scripts/build-openocd.sh, and I see that --enable-cmsis-dap
is present.
if you think that other options are required, please let me know, and I can consider a new release.
Thanks for the feedback. I digged into the code, and even looked at the diff between both versions and I can't see what could be going wrong.
Using the debug option, I can clearly see that we're failing at cmsis_dap_usb_open()#L283
- but since the auto-detection loop above hasn't been really modified since 0.9.0 - it should have detected the "CMSIS-DAP" substring into the product string. It looks like more a libusb
issue.
I'll try to build it.
As I suspected @ilg-ul, the problem lies inside the USB layer: by switching the hidapi
backend from hidapi-libusb
to hidapi-hidraw
, the adapter is properly detected. When running on the libusb
backend hid_enumerate()
doesn't returns all HID devices.
In fact, the version shipped with Ubuntu 16.04 is using the hidraw
backend:
$ ldd /usr/bin/openocd
...
libhidapi-hidraw.so.0 => /usr/lib/x86_64-linux-gnu/libhidapi-hidraw.so.0 (0x00007f694ce8e000)
...
Shall we switch to the hidraw
backend?
can you be more specific what changes need to be considered for the build script? remember, we need a portable solution, that works for all platforms.
According to the hidapi documentation:
HIDAPI has four back-ends:
* Windows (using hid.dll)
* Linux/hidraw (using the Kernel's hidraw driver)
* Linux/libusb (using libusb-1.0)
* FreeBSD (using libusb-1.0)
* Mac (using IOHidManager)
The hidraw backend is not available for FreeBSD, but your script doesn't support it anyway. You'll find below, the diff of my build-openocd.sh
script:
diff --git a/scripts/build-openocd.sh b/scripts/build-openocd.sh
old mode 100644
new mode 100755
index 6069b71..dae5612
--- a/scripts/build-openocd.sh
+++ b/scripts/build-openocd.sh
@@ -1085,7 +1085,7 @@ then
elif [ "${target_name}" == "debian" ]
then
HIDAPI_TARGET="linux"
- HIDAPI_OBJECT="hid-libusb.o"
+ HIDAPI_OBJECT="hid.o"
fi
if [ ! -f "${install_folder}/lib/libhid.a" ]
@@ -1124,7 +1124,7 @@ then
\
PKG_CONFIG_LIBDIR="${install_folder}/lib/pkgconfig":"${install_folder}/lib64/pkgconfig" \
\
- make clean "${HIDAPI_OBJECT}"
+ make clean "${HIDAPI_OBJECT}" COBJS=${HIDAPI_OBJECT}
# Make just compiles the file. Create the archive.
# No dynamic/shared libs involved.
Not sure why hid_enumerate()
doesn't returns that adapter using the libusb backend. This doesn't sounds like a libusb issue since I played with LD_LIBRARY_PATH
to enforce the use of my system libraries (instead of the local ones), but I can be wrong.
I asked the openocd-devel mailing list if there's any reasons to prefer the hidraw backend over the libusb one as Ubuntu is doing.
As noted above, I've been discussing on the openocd-devel mailing list and following their suggestions I compiled against hidapi 0.8.0-rc1 and it worked using both backends! A few commits might make all the difference:
https://github.com/signal11/hidapi/commit/a991328721b3b39cbc90f562b87df0bb1eeaf5c4 https://github.com/signal11/hidapi/commit/ec24f931007d75e061d26d6f9705790913f72fa0
I'm not able to spend more time trying to fix the build script, hopefully you'll consider the move and do a new release.
yes, I'll consider this for the next release, although it is a bit strange to use a version marked -rc1
that is several years old...
For sure. I should have noticed that Ubuntu 16.04 is shipping with libhidapi 0.8.0~rc1 (git20140201.3a66d4e+dfsg).
Thanks!
I'm not able to spend more time trying to fix the build script
you were right, fixing the script for 0.8.0-rc1 was tricky.
please try the new build script and let me know if the resulting binaries are functional.
I prepared a pre-release: https://github.com/gnuarmeclipse/openocd/releases/tag/gae-0.10.0-20170418
please confirm that the new version is functional in your environment. if possible, test both the 32-bits and 64-bits binaries.
Thanks! Indeed, both 32 and 64 bits pre-release versions are working! Congratulations!
thank you, in this case I'll complete the release.
and the merit for identifying the problem and suggesting a fix is mainly yours.
Just received my ATMEL SAMC21 XPLAINED PRO, and I immediately tried to play with it: the first thing I noticed is that the OpenOCD version which came with my distribution (Ubuntu 16.04) didn't included the required board script. I lazily ripped it, and tried to flash a blinky demo:
Ok, fair enough, SAMC21 support have been added lately: I needed to upgrade OpenOCD to the latest version available.
OpenOCD 0.9.0 is able to detect the CMSIS-DAP interface, but not the latest version? Running the above command using
sudo
didn't fixed it and confirmed that this is not a permission issue along with the following commands:I'm stuck. I'm willing to help, but I've no idea how.