pyocd / pyocd/pyOCD

OSError with CMSIS-DAP v2 on Windows

Open
#684 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

Hi,

I am observing the following error with CMSIS-DAP v2 (WinUSB) devices either running DAPLink ver. 0254 or Cypress KitProg3:

C:\Users\anjo>pyocd list
Exception ignored in: <function _AutoFinalizedObjectBase.del at 0x0000017F52B96E18>
Traceback (most recent call last):
File "c:\users\anjo\appdata\local\programs\python\python37\lib\site-packages\usb_objfinalizer.py", line 84, in del
self.finalize()
File "c:\users\anjo\appdata\local\programs\python\python37\lib\site-packages\usb_objfinalizer.py", line 144, in finalize
self._finalizer()
File "c:\users\anjo\appdata\local\programs\python\python37\lib\weakref.py", line 552, in call
return info.func(*info.args, **(info.kwargs or {}))
File "c:\users\anjo\appdata\local\programs\python\python37\lib\site-packages\usb_objfinalizer.py", line 104, in _do_finalize_object_ref
obj._do_finalize_object()
File "c:\users\anjo\appdata\local\programs\python\python37\lib\site-packages\usb_objfinalizer.py", line 71, in _do_finalize_object
self._finalize_object()
File "c:\users\anjo\appdata\local\programs\python\python37\lib\site-packages\usb\backend\libusb1.py", line 604, in _finalize_object
lib.libusb_unref_device(self.devid)
OSError: exception: access violation writing 0x0000000000000024

The problem appears when running any command in pyOCD, however, commands itself do work. Looks like this is known issue with pyusb/libusb:
https://github.com/pyusb/pyusb/issues/203
https://github.com/pyusb/pyusb/pull/227
https://github.com/libusb/libusb/issues/412

I can reproduce this on Windows only with Python3 + libusb 1.0.22. In order not to confuse user with this exception, I propose to update README with an recommendation to use libusb 1.0.21 under Windows until problem is fixed.

OS: Win10 Pro x64
Python: v3.7.3 x64
libusb: MinGW64 v1.0.22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the README's Windows installation guidance in light of the reported pyocd command error with Python 3 and libusb 1.0.22. Document the recommendation to use libusb 1.0.21 on Windows until the pyusb/libusb problem is fixed, then verify that the wording clearly covers the affected setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.