Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError with CMSIS-DAP v2 on Windows #684

Open
AndriiLishchynskyi opened this issue Jun 4, 2019 · 10 comments
Open

OSError with CMSIS-DAP v2 on Windows #684

AndriiLishchynskyi opened this issue Jun 4, 2019 · 10 comments

Comments

@AndriiLishchynskyi
Copy link

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:
pyusb/pyusb#203
pyusb/pyusb#227
libusb/libusb#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

@eamars
Copy link

eamars commented Aug 7, 2019

Can reproduce with Python 3.7 + libusb 1.0.22 + pyocd-0.21

OS: Window 10 Pro 1809 (Build 17763.557)

@flit
Copy link
Member

flit commented Aug 17, 2019

Yeah, unfortunately there seems to be a bug in pyusb in how it handles releasing objects in the finalizer.

Good suggestion to recommend using libusb 1.0.21 instead. Were there any fixes in 1.0.22 that could cause problems by reverting to the earlier version?

flit added a commit to flit/pyOCD that referenced this issue Aug 17, 2019
@mcuee
Copy link

mcuee commented Dec 7, 2019

Have you tried latest pyusb and latest libusb?

I can no longer reproduce the issue in Windows 10, git pyusb and git libusb.
pyusb/pyusb#203

@mcuee
Copy link

mcuee commented Dec 7, 2019

pyusb/pyusb#227
pyusb pull request #227 has been merged.

@flit
Copy link
Member

flit commented Dec 7, 2019

@mcuee I haven't yet tried it, but I did notice just yesterday that pyusb/pyusb#227 has been merged. (Thanks for merging the fix!) It would be really helpful to have a new pyusb release.

@mcuee
Copy link

mcuee commented Dec 11, 2019

Thanks. Yes now we have a new maintainer for pyusb and we will work towards a new pyusb release soon.

@flit
Copy link
Member

flit commented Dec 11, 2019

@mcuee Thanks very much for taking over maintainership of pyusb!

@AndriiLishchynskyi
Copy link
Author

@mcuee, with using latest pyusb from git, the problem seems to be fixed

@mcuee
Copy link

mcuee commented Dec 12, 2019

@flit Thanks. I am not really the maintainer myself, rather I am helping out on the supporting and testing side of pyusb, similar to my role in libusb, libusb-win32 and libusbk.

Jonas Malaco is the current developer/maintainer of pyusb.

@flit
Copy link
Member

flit commented Dec 21, 2019

@mcuee Well, either way, your help with these critical projects is greatly appreciated. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants