Usb4java library, error while claiming an interfac

2019-04-15 11:52发布

问题:

Here I use the library usb4java to access to my usb device.

The problem is I have an error while I try to claim an interface of my usb device. The error is on this line:

int msg = LibUsb.claimInterface(deviceHandler, 1);

error: USB error 3: Unable to claim interface: Access denied (insufficient permissions)

Is there someone who know why I have this error or how fix it ?

回答1:

I have the same issue you got, and my env is Mac OS X 10.9

After a long search with google, I finally found this just get the names of USB devices attached to a system? which helped me out, now my code works like charm。

solution is here,Cause mac will automatically claim devices, and we could create a dummy driver for it.

Here is step how to do it.

  1. create Info.plist in /System/Library/Extensions/Proxmark3.kext/Contents , And you should create parent folder if is missing, file content shuold be like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <!-- This is a dummy driver which binds to Proxmark. It -->
    <!-- contains no actual code; its only purpose is to     -->
    <!-- prevent Apple's USBHID driver from exclusively      -->
    <!-- opening the device.                                 -->
    <plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleIconFile</key>
        <string></string>
        <key>CFBundleIdentifier</key>
        <string>com.proxmark.driver.dummy</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundlePackageType</key>
        <string>KEXT</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1.0.0d1</string>
        <key>IOKitPersonalities</key>
        <dict>
            <!-- The Proxmark3 USB interface -->
            <key>Proxmark3</key>
            <dict>
                <key>CFBundleIdentifier</key>
                <string>com.apple.kpi.iokit</string>
                <key>IOClass</key>
                <string>IOService</string>
                <key>IOProviderClass</key>
                <string>IOUSBInterface</string>
                <key>bConfigurationValue</key>
                <integer>1</integer>
                <key>bInterfaceNumber</key>
                <integer>0</integer>
                <key>idProduct</key>
                <integer>{your-usb-hardware-product-id}</integer>
                <key>idVendor</key>
                <integer>{your-usb-hardware-vendor-id}</integer>
            </dict>
        </dict>
        <key>OSBundleLibraries</key>
        <dict>
            <key>com.apple.iokit.IOUSBFamily</key>
            <string>1.8</string>
        </dict>
    </dict>
</plist>

note: {your-usb-hardware-product-id} and {your-usb-hardware-vendor-id} have to be your own hardware ids, which can be obtained from About this mac - System Report - Hardware - USB .

  1. Enter /System/Library/Extensions, and run as ROOT

sudo chown -R root:wheel Proxmark3.kext

sudo chmod -R 755 Proxmark3.kext

sudo kextcache -system-caches

  1. reboot your system and see the result.


回答2:

For Linux system it sounds as if the user has no rights to access the USB devices.

This can be changed by adding a rule in /etc/udev/rules.d, for example with a name "50-usb-permissions.rules", and the content

SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="5678",
    MODE="0666",GROUP="users"

while hex numbers 1234 are the vendorid and 5678 the productid of the attached USB device, which can be found by "lsusb -v". The sample rule allows the user group "users" access to the specified usb device. After a reboot the rule will be applied.

Depending in the Linux version the pathes may be different.



回答3:

I got this error when adb server was running on MacOS. Restarting the computer released the interface so that I could claim it again. However, any time adb started, it would lock up the USB interface and a restart of the computer was required again.