CMSIS DAP V1 Initialisation issue on Windows
Hi, I'm working on a USB Low Speed CMSIS DAP V1 probe and I am seeing a strange traceback when trying to intitialise the probe:
Downloads\pyocd-windows-0.39.0>pyocd.exe cmd -vvvvv -t py32f002bx5 -c reset
0002249 D Project directory: C:\Users\REDACTED\Downloads\pyocd-windows-0.39.0 [session]
0002327 D Project directory: C:\Users\REDACTED\Downloads\pyocd-windows-0.39.0 [session]
0002749 D CMSIS-DAP v1 probe 1234: firmware version V1.2, protocol version 1.3.0 [dap_access_cmsis_dap]
0002874 D suppressing error from attempting to open device <pyocd.probe.pydapaccess.dap_access_cmsis_dap.DAPAccessCMSISDAP object at 0x00000200EFE7B310>: DAP_Info Packet Size 64 exceeds endpoint wMaxPacketSize 8 [cmsis_dap_probe]
0004564 I Target type is py32f002bx5 [board]
0004595 C Error: already open [__main__]
Traceback (most recent call last):
File "pyocd\__main__.py", line 161, in run
status = cmd.invoke()
^^^^^^^^^^^^
File "pyocd\subcommands\commander_cmd.py", line 75, in invoke
PyOCDCommander(self._args, cmds).run()
File "pyocd\commands\commander.py", line 83, in run
if do_connect and not self.connect():
^^^^^^^^^^^^^^
File "pyocd\commands\commander.py", line 224, in connect
if not self._post_connect():
^^^^^^^^^^^^^^^^^^^^
File "pyocd\commands\commander.py", line 251, in _post_connect
self.session.open(init_board=not self.args.no_init)
File "pyocd\core\session.py", line 549, in open
self._probe.open()
File "pyocd\probe\shared_probe_proxy.py", line 55, in open
self._probe.open()
File "pyocd\probe\cmsis_dap_probe.py", line 277, in open
self._link.open()
File "pyocd\utility\concurrency.py", line 29, in _locking
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pyocd\probe\pydapaccess\dap_access_cmsis_dap.py", line 752, in open
self._interface.open()
File "pyocd\probe\pydapaccess\interface\hidapi_backend.py", line 144, in open
self.device.open_path(self.device_info['path'])
File "hid.pyx", line 155, in hid.device.open_path
RuntimeError: already open
Don't focus on the wMaxPacketSize error too much, this doesn't happen on macOS. I assume the _is_open property is not set correctly when encountering the size error, or the interface is not closed properly. I would also appreciate some pointers to where that packet size check is coming from, I don't believe it should be treated as an error, but a warning.
I think this function is causing the size issue, but don't think that's the real issue. https://github.com/pyocd/pyOCD/blob/2db39e1091456f6c8e717a4881297c68a38b83e2/pyocd/probe/pydapaccess/interface/hidapi_backend.py#L285
Ok, I think I found a problem for both Windows and Linux when using Low speed DAP V1 probes (which openOCD has no problem with).
pyhid on macos uses hidraw, which actually reads the hid descriptors to see that the report_count is always 64 bytes. On windows and linux, it uses libusb, which only has access to the endpoint descriptors.
This section here is incorrect:
https://github.com/pyocd/pyOCD/blob/2db39e1091456f6c8e717a4881297c68a38b83e2/pyocd/probe/pydapaccess/interface/hidapi_backend.py#L126-L132
It should never assume that the report size is the same as the interface size. Furthermore, CMSIS-DAP doesn't support packets smaller than 64 bytes. I can see a few ways of fixing it to improve compatibility:
- always use hidraw (takes care of everything)
- parse the hid report manually and extract the report count (use that for writes, not needed for reads)
- initialise the report_*_size to
max(endpoint.wMaxPacketSize, 64)
Option 2 would be the most correct and not too difficult to implement. Option 3 would be the quickest fix and won't affect V2 devices in any way.
Like I said, openOCD and pyOCD on macos work perfectly and I would really like it to work everywhere.
@BogdanTheGeek, which CMSIS-DAP v1 probe are you using?
@KeilChris I ported DAPLink to a microcontroller that can only do low speed USB. The source code is available here: https://github.com/BogdanTheGeek/ch32v003-daplink I have tested it an it works perfectly with openOCD, because it respects the hid descriptor.
I am happy to make a PR with wichever solution you guys prefer.
There has been a regression in 0.40.0 that now breaks this on macos too, as https://github.com/pyocd/pyOCD/issues/1846 mentions. We are going the wrong way guys, I know I said to be consistent, but that doesn't mean break all of them :)
@BogdanTheGeek , thank you for reporting this issue, and for the valuable suggestions.
We’ve revised the HIDAPI backend. Our primary goal was to re-enable previously working probes without introducing regressions. Accordingly, we kept the Windows implementation closely aligned with prior behavior and focused on macOS fixes by retrieving and parsing the HID report descriptor to determine the correct report sizes for HID reads/writes. These changes are included in PR #1854.
We would appreciate any feedback, and if possible, please test with the updated build artifacts and share your results: https://github.com/pyocd/pyOCD/actions/runs/19635757925#artifacts
Thanks
@DavidLesnjak tested on all platforms:
- macOS is back to working
- Windows now works!!!!!
- linux is still broken ( cannot even find the probe )
Thanks for testing! We only updated the HIDAPI backend, which is used on macOS and Windows. On Linux, pyOCD uses the PyUSB backend, so the recent changes don’t apply there.
To help debug Linux, could you share:
- pyOCD debug log (-vvvvv) from a failed run
- USB traffic log (e.g., usbmon/Wireshark capture)
Thanks
@DavidLesnjak I tried forcing hidapi backend on linux and it still didn't work. I will come back with the testing you asked for, but I was just seeing index our of range with no traceback from where it was coming from. (for once it wasn't a udev rules issue)
Bus 001 Device 048: ID 1209:d003 Generic RV003 CMSIS-DAP V1.3
> ./pyocd --version
0.40.1.dev6+g46941d56b
> time ./pyocd list -vvvvvvvv -p
0000345 D Project directory: /home/bogdan/Downloads [session]
0000348 D [Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=3434 PID=0323). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help. [pyusb_backend]
0000366 D [Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=046d PID=c332). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help. [pyusb_backend]
0000366 D [Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=3434 PID=0323). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help. [pyusb_v2_backend]
0000367 D [Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=046d PID=c332). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help. [pyusb_v2_backend]
0000368 D [Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=3434 PID=0323). This can probably be remedied with a udev rule. See <https://github.com/pyocd/pyOCD/tree/master/udev> for help. [pyusb_backend]
0007639 C index out of range [__main__]
./pyocd list -vvvvvvvv -p 0.61s user 0.14s system 9% cpu 7.774 total
Ive attached the capture for the same command as above, but filtered for only this usb device pyocd.pcap.zip
Hello @BogdanTheGeek,
from the output this seems to be an access problem with your DAP implementation. Can you check https://developer.arm.com/documentation/109243/1-1/CMSIS-DAP-2-x/Linux, please? It explains how to create udev rules that you ned to access it. You need to set the correct {idVendor} and {idProduct} for your own USB device (3434/0323).
@KeilChris that is not correct, none if those udev logs are for my device (again, works perfectly with openocd on the same machine). The logs don't even mention my device in any capacity, something breaks internally and because of the logging architecture, there's no way to traceback where the error came from.
On Mon, 1 Dec 2025, 07:44 Christopher Seidl, @.***> wrote:
KeilChris left a comment (pyocd/pyOCD#1825) https://github.com/pyocd/pyOCD/issues/1825#issuecomment-3595066322
Hello @BogdanTheGeek https://github.com/BogdanTheGeek, from the output this seems to be an access problem with your DAP implementation. Can you check https://developer.arm.com/documentation/109243/1-1/CMSIS-DAP-2-x/Linux, please? It explains how to create udev rules that you ned to access it. You need to set the correct {idVendor} and {idProduct} for your own USB device (3434/0323).
— Reply to this email directly, view it on GitHub https://github.com/pyocd/pyOCD/issues/1825#issuecomment-3595066322, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDKK6TJ457IPG7DMHVIEKD37PWVXAVCNFSM6AAAAACJCSJ5TCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKOJVGA3DMMZSGI . You are receiving this because you were mentioned.Message ID: @.***>