fluxengine icon indicating copy to clipboard operation
fluxengine copied to clipboard

Error: unable to claim interface: LIBUSB_ERROR_ACCESS

Open erichelgeson opened this issue 4 years ago • 4 comments

I successfully compiled master df1ac74 on my intel macos 10.15.7 and receive the following:

./fluxengine read mac
Reading from: :d=0:s=0-1:t=0-79
Using GreaseWeazle with serial number GW0101717747431232004E4B52
Error: unable to claim interface: LIBUSB_ERROR_ACCESS

Debugging so far I attempted to run as root with no change, unloaded all non-apple kexts. Ran as root with no change (via sudo and su -).

When the device is plugged in I see devices under /dev (cu.usbmodem14301 & tty.usbmodem14301)

I am able to read with gw and fluxengine on my windows 10 PC, so the hardware side seems fine. I am able to read disks via gw on my mac.

Using a STM32F1 bluepill with adapter board. Flashed with gw 0.22.

Hopefully I didn't just miss something obvious, and thanks for the great software.

erichelgeson avatar Feb 20 '21 17:02 erichelgeson

It looks like the OSX serial driver is claiming the device, preventing the FluxEngine client from accessing it: https://medium.com/@kondal.kolipaka/error-libusb-claim-interface-failed-with-libusb-error-access-c85708c5f43

davidgiven avatar Feb 20 '21 18:02 davidgiven

It appears I 10.15.x does not have the driver mentioned in that article

$ sudo kextunload -b com.apple.driver.AppleUSBFTDI
(kernel) Kext com.apple.driver.AppleUSBFTDI not found for unload request.
Failed to unload com.apple.driver.AppleUSBFTDI - (libkern/kext) not found.

I was able to find that driver mentioned here https://ftdichip.com/drivers/vcp-drivers/ and was able to install it/load it: sudo kextload -b com.FTDI.driver.FTDIUSBSerialDriver

But I can not unload any Apple ones - the one coordenate that looks to be the one (though I am guessing) fails:

$ sudo kextunload -b com.apple.driver.usb.serial
(kernel) Can't remove kext com.apple.driver.usb.serial; services failed to terminate - 0xdc008018.
Failed to unload com.apple.driver.usb.serial - (libkern/kext) kext is in use or retained (cannot unload).

The names do not match what 10.15 has. There is no specific Apple FTDI or Serial USB drivers I can see that I are able to be unload:

$ kextstat | grep -i Serial
   88   10 0xffffff7f80f6c000 0xe000     0xe000     com.apple.iokit.IOSerialFamily (11) 549F5E3F-1A70-34C7-B631-1B6C260A5273 <8 7 6 5 3 1>
  133    2 0xffffff7f845c1000 0x2e000    0x2e000    com.apple.driver.AppleOnboardSerial (1.0) 04C224BA-2B2E-3710-9088-F2B580F209ED <88 85 8 6 5 3 1>
  170    0 0xffffff7f84886000 0xa000     0xa000     com.apple.iokit.IOBluetoothSerialManager (7.0.6f8) 7F31357D-6ED1-31C1-B1BB-4F6ECC325A75 <88 8 6 5 3 1>
  189    0 0xffffff7f845f5000 0x7000     0x7000     com.FTDI.driver.FTDIUSBSerialDriver (2.4.4) B137605C-32D8-3E81-89B6-E1F8039FC427 <88 64 6 5 3 1>
  190    1 0xffffff7f846cf000 0x6000     0x6000     com.apple.driver.usb.serial (6.0.0) FC10C12C-E713-344A-A233-F90CEFDBFA84 <88 21 6 5 3 1>

$ kextstat | grep -i USB
   19    2 0xffffff7f80dd2000 0x4000     0x4000     com.apple.driver.AppleUSBHostMergeProperties (1.2) 8BB30FDB-96F5-3EC8-B246-F0C4F91A7562 <5 3 1>
   20    9 0xffffff7f80dd6000 0xe000     0xe000     com.apple.driver.usb.AppleUSBCommon (1.0) B1BAE081-4EBD-3BD2-8699-68CAF8D86C9A <6 5 3 1>
   21   20 0xffffff7f80de4000 0xfa000    0xfa000    com.apple.iokit.IOUSBHostFamily (1.2) 0495ACDF-FE50-3D21-B8F0-0CE099678419 <20 19 18 8 7 6 5 3 1>
   24    1 0xffffff7f8130a000 0x34000    0x34000    com.apple.iokit.IOUSBMassStorageDriver (157.140.1) B996556C-8E44-3CDA-BE58-9E7B66CA396C <23 22 21 13 7 6 5 3 1>
   42    2 0xffffff7f81456000 0x15000    0x15000    com.apple.driver.AppleUSBTDM (489.120.1) A9F252DD-D1DE-3D4E-9DDF-BEF2BEC435F8 <41 36 24 23 22 21 8 7 6 5 3 1>
   62    1 0xffffff7f839a5000 0x58000    0x58000    com.apple.driver.usb.AppleUSBXHCI (1.2) 74B2F241-D11F-35D6-ABF3-4A7F278D879A <21 20 12 8 7 6 5 3 1>
   63    0 0xffffff7f83c5b000 0x35000    0x35000    com.apple.driver.usb.AppleUSBXHCIPCI (1.2) BC4BBC92-050F-31EC-89D0-5B24C92E7996 <62 21 20 13 12 8 7 6 5 3 1>
   64    1 0xffffff7f818c1000 0x99000    0x99000    com.apple.iokit.IOUSBFamily (900.4.2) F778E0DD-D561-32BD-BB0A-A3ACB9F72671 <21 20 13 8 6 5 3 1>
   70    3 0xffffff7f8197e000 0x9000     0x9000     com.apple.driver.usb.AppleUSBVHCICommon (1.0) B73E5C62-32A5-30B6-A017-94CDE09D9BF0 <21 20 8 6 5 3 1>
   71    1 0xffffff7f81987000 0xd000     0xd000     com.apple.driver.usb.AppleUSBVHCICommonBCE (1.0) 403F6F06-1824-3B5D-91FA-ED853D575D60 <70 67 20 8 6 5 3 1>
   72    1 0xffffff7f81994000 0x28000    0x28000    com.apple.driver.usb.AppleUSBVHCI (1.2) 3DBCADE7-0C47-30F7-80F9-52BE8E3BC1E4 <70 21 20 8 7 6 5 3 1>
   73    0 0xffffff7f819c0000 0x4000     0x4000     com.apple.driver.usb.AppleUSBVHCIBCE (1.2) A4363027-002A-3A86-B87A-DC456326FB10 <72 71 70 67 21 20 12 8 7 6 5 3 1>
  106    3 0xffffff7f80eee000 0x8000     0x8000     com.apple.driver.usb.AppleUSBHostCompositeDevice (1.2) F4942637-A6A9-37B8-86A7-34535B0E30C3 <21 20 7 6 5 3 1>
  107    4 0xffffff7f81b8b000 0x8000     0x8000     com.apple.driver.usb.networking (5.0.0) 4FD6761A-BA62-34F0-8810-FBB1DFF57A44 <21 7 6 5 3 1>
  108    3 0xffffff7f82a95000 0x8000     0x8000     com.apple.driver.usb.cdc (5.0.0) 76EE2BFC-2674-324A-8F9F-408A7B949FA8 <107 106 21 6 5 3 1>
  109    0 0xffffff7f82a9d000 0x11000    0x11000    com.apple.driver.usb.cdc.ncm (5.0.0) CC150672-4E2A-3F58-94C3-04670F8DFF0F <108 107 106 32 21 17 7 6 5 3 1>
  189    0 0xffffff7f845f5000 0x7000     0x7000     com.FTDI.driver.FTDIUSBSerialDriver (2.4.4) B137605C-32D8-3E81-89B6-E1F8039FC427 <88 64 6 5 3 1>
  190    1 0xffffff7f846cf000 0x6000     0x6000     com.apple.driver.usb.serial (6.0.0) FC10C12C-E713-344A-A233-F90CEFDBFA84 <88 21 6 5 3 1>
  191    0 0xffffff7f846d5000 0x8000     0x8000     com.apple.driver.usb.cdc.acm (5.0.0) 792BCB82-E6B8-3334-9BA2-2DFE99A25026 <190 108 107 106 88 21 6 5 3 1>
  192    0 0xffffff7f846dd000 0xc000     0xc000     com.apple.driver.usb.cdc.ecm (5.0.0) BA2432F2-3DF0-337F-B359-999261DBD472 <108 107 32 21 19 6 5 3 1>

erichelgeson avatar Feb 20 '21 19:02 erichelgeson

I'm afraid this is well beyond my knowledge of OSX.

The issue here is that the GW exposes a serial device, which the OS is claiming, and that's preventing the FluxEngine client from accessing it. This isn't a problem on Linux because there, the OS will release the device if a libusb program wants to use it. But that seems not to be the case here, or on Windows. This could all be avoided by talking the GW via the serial device, which is what the GW client does, but that's not easy to do given the FluxEngine client architecture. I'm going to have to work on this.

davidgiven avatar Feb 20 '21 22:02 davidgiven

A bit beyond me here too on OSX. If GW and FE both spoke the same USB protocol then you wouldn't have to switch the drivers back and forth in windows. I may just jump over to linux now as my ultimate goal was to script GW & FE together.

erichelgeson avatar Feb 20 '21 23:02 erichelgeson