greatscottgadgets / facedancer

Implement your own USB device in Python, supported by a hardware peripheral such as Cynthion or GreatFET
BSD 3-Clause "New" or "Revised" License
785 stars 119 forks source link

LIBUSB_ERROR_BUSY upon shutdown #99

Closed mipek closed 4 months ago

mipek commented 4 months ago

I just received my Cynthion yesterday - thank you, it's awesome!

However, I'm having a little problem: Upon shutdown, when the libusb context is getting destroyed, I get the error LIBUSB_ERROR_BUSY (using usbproxy):

Traceback (most recent call last):
  File "/mnt/source/facedancer/venv/lib/python3.12/site-packages/facedancer/proxy.py", line 356, in _destroy_libusb_context
    cls.device_handle.attachKernelDriver(number)
  File "/mnt/source/facedancer/venv/lib/python3.12/site-packages/usb1/__init__.py", line 1207, in attachKernelDriver
    mayRaiseUSBError(
  File "/mnt/source/facedancer/venv/lib/python3.12/site-packages/usb1/__init__.py", line 127, in mayRaiseUSBError
    __raiseUSBError(value)
  File "/mnt/source/facedancer/venv/lib/python3.12/site-packages/usb1/__init__.py", line 119, in raiseUSBError
    raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)
usb1.USBErrorBusy: LIBUSB_ERROR_BUSY [-6]

I'm able to properly re-attach the kernel driver when the "attachKernelDriver" and "releaseInterface" calls are swapped around. I don't really know about libusb and its inner workings but I figured I'll just put this up for discussion at least.

antoinevg commented 4 months ago

Oh nice catch, thank you!