Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Cannot get code-less kext to release USB HID device

Hello,


I have built a protoype USB device using an expandIO-USB chip from Hexwax.com and written some Haskell and C code to talk to it. This works well on Linux. I installed GHC and mac ports, then installed libusb libusb (1.0) and linked and built my Linux code but when I run it I always get this output, this is from the C program: (bold is output from my code, libusb does the rest in diagnostic mode)

libusb: 0.392273 info [darwin_open] device open for access

No kernel driver attached to this device

libusb: 0.393006 error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access

sw error: LIBUSB_ERROR_ACCESS

expandIO-USB handle closed

libusb: 0.393262 info [event_thread_main] thread exiting

USB connection released


I understand *why* this is happening. That was over a week ago and since then I have read everything that I can find and eventually found the concept of a code-less kext. Awesome. Just what I want.... except after trying and trying and trying I just cannot seem to stop the kernel from getting in the way. My software is trying to be portable hence using "libusb" as I really don't want to have to write IOKit based code just for OS X to use when I know that the solution is just inches away!


Here is the Info.plist file I am using, it gives me one warning which I have never managed to fix but it seems to still load, here it is:


<?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";>

<plist version="1.0">

<dict>

<key>CFBundleDevelopmentRegion</key>

<string>English</string>

<key>CFBundleGetInfoString</key>

<string>Hexwax expandIO-USB Shield</string>

<key>CFBundleIdentifier</key>

<string>HexwaxShield.kext</string>

<key>CFBundleInfoDictionaryVersion</key>

<string>6.0</string>

<key>CFBundleName</key>

<string>Hexwax expandIO-USB Shield</string>

<key>CFBundlePackageType</key>

<string>KEXT</string>

<key>CFBundleSignature</key>

<string>????</string>

<key>CFBundleVersion</key>

<string>6.0</string>

<key>IOKitPersonalities</key>

<dict>

<key>HexwaxShield</key>

<dict>

<key>CFBundleIdentifier</key>

<string>com.apple.kpi.iokit</string>

<key>IOClass</key>

<string>IOService</string>

<key>IOProviderClass</key>

<string>IOUSBInterface</string>

<key>idProduct</key>

<integer>2880</integer>

<key>idVendor</key>

<integer>306</integer>

</dict>

</dict>

</dict>

</plist>



When I load the extension like this:


sudo kextutil -v 6 /System/Library/Extensions/HexwaxShield.kext/



I get the following output which on the surface of it seems to indicate that everything is cool and funky and ought to work:


Kext user-space log filter changed from 0xff2 to 0xfff.

Kext kernel-space log filter changed from 0xff2 to 0xfff.

Kext library architecture set to x86_64.

No kernel file specified, using '/mach_kernel'

Kext library recording diagnostics for: validation authentication dependencies warnings.

Warnings:

Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):

HexwaxShield



/System/Library/Extensions/HexwaxShield.kext appears to be loadable (not including linkage for on-disk libraries).

Loading /System/Library/Extensions/HexwaxShield.kext.

Reading load info for 1 kext.

Reading loaded kext info from kernel.

(kernel) User-space log flags changed from 0x0 to 0xfff.

(kernel) Received 'Get Loaded Kext Info' request from user space.

(kernel) Returning loaded kext info.

Loaded kext info:

{

}



Adding /System/Library/Extensions/HexwaxShield.kext to mkext.

Created mkext for architecture x86_64 containing 1 kexts.

Loading /System/Library/Extensions/HexwaxShield.kext.

(kernel) User-space log flags changed from 0x0 to 0xfff.

(kernel) Received kext load request from user space.

(kernel) Received request from user space to load kext HexwaxShield.kext.

(kernel) Recorded kext HexwaxShield.kext as a candidate for inclusion in prelinked kernel.

(kernel) Kext HexwaxShield.kext sending 1 personality to the IOCatalogue and starting matching.

(kernel) Kext HexwaxShield.kext has no executable; removing any personalities naming it.

(kernel) Kext HexwaxShield.kext removing all personalities naming it from the IOCatalogue.

(kernel) Kext HexwaxShield.kext loaded.

Successfully loaded /System/Library/Extensions/HexwaxShield.kext.

/System/Library/Extensions/HexwaxShield.kext successfully loaded (or already loaded).

EricTheMac:hexwax cexplymouth$


I don't understand the warning enough to be able to fix it but it is *just* a warning at the end of the day! Despite this, when I unplug the device and plug it back in I get the same message about not being able to claim the interface because it is already taken.


I have also rebooted the machine more times than I care to mention (because of the successfully loaded (or already loaded)) but to no avail and not understanding the OS X internals too well means that I am not even sure that my kernel extension is still active after a reboot without me having issued some other incantation that I have yet to see.


I really want to be moving on with this on Linux and OS X and this is proving to be troublesome so if anybody can shed any light or even offer a solution then I would be most appreciative!


Many thanks,


Sean Charles.


PS: The output from the USBProber tool for the device when it is plugged in is here in case it helps somebody figure it out...


****BUS PROBE ****

Full Speed device @ 2 (0x3A200000): ............................................. Composite device: "expandIO-USB\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0 00\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0 00\000\000\000\000\000\000\000\000\000\000\000\000\000"

Port Information: 0x101a

Not Captive

Attached to Root Hub

External Device

Connected

Enabled

Device Descriptor

Descriptor Version Number: 0x0200

Device Class: 0 (Composite)

Device Subclass: 0

Device Protocol: 0

Device MaxPacketSize: 8

Device VendorID/ProductID: 0x0B40/0x0132 (unknown vendor)

Device Version Number: 0x0010

Number of Configurations: 2

Manufacturer String: 2 "Firmware Factory Ltd\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000 \000\000\000"

Product String: 1 "expandIO-USB\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0 00\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0 00\000\000\000\000\000\000\000\000\000\000\000\000\000"

Serial Number String: 3 "21436587-2455-011F080C7-02AF8598B518\000\000\000\000\000\000\000\000\000\000\0 00\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"

Configuration Descriptor

Length (and contents): 41

Raw Descriptor (hex) 0000: 09 02 29 00 01 01 00 80 32 09 04 00 00 02 03 00

Raw Descriptor (hex) 0010: 00 00 09 21 11 01 00 01 22 2F 00 07 05 81 03 40

Raw Descriptor (hex) 0020: 00 01 07 05 01 03 40 00 01

Number of Interfaces: 1

Configuration Value: 1

Attributes: 0x80 (bus-powered)

MaxPower: 100 ma

Interface #0 - HID

Alternate Setting 0

Number of Endpoints 2

Interface Class: 3 (HID)

Interface Subclass; 0

Interface Protocol: 0

HID Descriptor

Descriptor Version Number: 0x0111

Country Code: 0

Descriptor Count: 1

Descriptor 1

Type: 0x22 (Report Descriptor)

Length (and contents): 47

Raw Descriptor (hex) 0000: 06 A0 FF 09 01 A1 01 09 03 15 00 26 FF 00 75 08

Raw Descriptor (hex) 0010: 95 40 81 02 09 04 15 00 26 FF 00 75 08 95 40 91

Raw Descriptor (hex) 0020: 02 09 05 15 00 26 FF 00 75 08 95 08 B1 02 C0

Parsed Report Descriptor:

Usage Page (65440)

Usage 1 (0x1)

Collection (Application)

Usage 3 (0x3)

Logical Minimum......... (0)

Logical Maximum......... (255)

Report Size............. (8)

Report Count............ (64)

Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)

Usage 4 (0x4)

Logical Minimum......... (0)

Logical Maximum......... (255)

Report Size............. (8)

Report Count............ (64)

Output.................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)

Usage 5 (0x5)

Logical Minimum......... (0)

Logical Maximum......... (255)

Report Size............. (8)

Report Count............ (8)

Feature................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)

End Collection

Endpoint 0x81 - Interrupt Input

Address: 0x81 (IN)

Attributes: 0x03 (Interrupt no synchronization data endpoint)

Max Packet Size: 64

Polling Interval: 1 ms

Endpoint 0x01 - Interrupt Output

Address: 0x01 (OUT)

Attributes: 0x03 (Interrupt no synchronization data endpoint)

Max Packet Size: 64

Polling Interval: 1 ms

Configuration Descriptor

Length (and contents): 41

Raw Descriptor (hex) 0000: 09 02 29 00 01 02 00 80 32 09 04 00 00 02 03 00

Raw Descriptor (hex) 0010: 00 00 09 21 11 01 00 01 22 2F 00 07 05 81 03 40

Raw Descriptor (hex) 0020: 00 01 07 05 01 03 40 00 01

Number of Interfaces: 1

Configuration Value: 2

Attributes: 0x80 (bus-powered)

MaxPower: 100 ma

Interface #0 - HID

Alternate Setting 0

Number of Endpoints 2

Interface Class: 3 (HID)

Interface Subclass; 0

Interface Protocol: 0

HID Descriptor

Descriptor Version Number: 0x0111

Country Code: 0

Descriptor Count: 1

Descriptor 1

Type: 0x22 (Report Descriptor)

Length (and contents): 47

Raw Descriptor (hex) 0000: 06 A0 FF 09 01 A1 01 09 03 15 00 26 FF 00 75 08

Raw Descriptor (hex) 0010: 95 40 81 02 09 04 15 00 26 FF 00 75 08 95 40 91

Raw Descriptor (hex) 0020: 02 09 05 15 00 26 FF 00 75 08 95 08 B1 02 C0

Parsed Report Descriptor:

Usage Page (65440)

Usage 1 (0x1)

Collection (Application)

Usage 3 (0x3)

Logical Minimum......... (0)

Logical Maximum......... (255)

Report Size............. (8)

Report Count............ (64)

Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)

Usage 4 (0x4)

Logical Minimum......... (0)

Logical Maximum......... (255)

Report Size............. (8)

Report Count............ (64)

Output.................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)

Usage 5 (0x5)

Logical Minimum......... (0)

Logical Maximum......... (255)

Report Size............. (8)

Report Count............ (8)

Feature................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)

End Collection

Endpoint 0x81 - Interrupt Input

Address: 0x81 (IN)

Attributes: 0x03 (Interrupt no synchronization data endpoint)

Max Packet Size: 64

Polling Interval: 1 ms

Endpoint 0x01 - Interrupt Output

Address: 0x01 (OUT)

Attributes: 0x03 (Interrupt no synchronization data endpoint)

Max Packet Size: 64

Polling Interval: 1 ms



****IOREGISTRY****

0x3a: UHC5@1A,1 <class IOPCIDevice>

AppleUSBUHCI <class AppleUSBUHCI>

1: UHCI Root Hub Simulation@1A,1 <class IOUSBRootHubDevice>

AppleUSBHub <class AppleUSBHub>

IOUSBInterface@0 <class IOUSBInterface>

2: expandIO-USB@3a200000 <class IOUSBDevice>

IOUSBCompositeDriver <class IOUSBCompositeDriver>

IOUSBInterface@0 <class IOUSBInterface>

IOUSBHIDDriver <class IOUSBHIDDriver>

IOHIDInterface <class IOHIDInterface>

IOHIDLibUserClient <class IOHIDLibUserClient>

IOHIDLibUserClient <class IOHIDLibUserClient>

iMac, OS X Mountain Lion (10.8.3)

Posted on May 12, 2013 2:19 PM

Reply

There are no replies.

Cannot get code-less kext to release USB HID device

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.