USBInterfaceOpen always reports kIOReturnExclusiveAccess error

I recently ran into this headache problem, I already spent a week on this problem but still failed. Hope you can help me throw this stone away, thanks a lot.

My Problem: Our component USB drive for iPhone, there is actually an SD card in this storage device. Now we want to develop a Mac application to update the firmware for this storage device. But every time I connect a storage device to the Mac, the Mac mounts it automatically and I always fail with kIOReturnExclusiveAccess when calling USBInterfaceOpen .

I am also trying to write a codeless kext to increase the probe counter, but it still doesn't work. I don't know why I am wrong, or some errors for writing the kext code file, like writing wrong IOClass, wrong bundle id.

My code kext info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>BuildMachineOSBuild</key>
  <string>14E46</string>
  <key>CFBundleDevelopmentRegion</key>
  <string>en</string>
  <key>CFBundleIdentifier</key>
  <string>com.mophie.MyDriverTest3</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundleName</key>
  <string>MyDriverTest3</string>
  <key>CFBundlePackageType</key>
  <string>KEXT</string>
  <key>CFBundleSignature</key>
  <string>????</string>
  <key>CFBundleVersion</key>
  <string>1.0.3</string>
  <key>DTCompiler</key>
  <string>com.apple.compilers.llvm.clang.1_0</string>
  <key>DTPlatformBuild</key>
  <string>6E35b</string>
  <key>DTPlatformVersion</key>
  <string>GM</string>
  <key>DTSDKBuild</key>
  <string>14D125</string>
  <key>DTSDKName</key>
  <string>macosx10.10</string>
  <key>DTXcode</key>
  <string>0640</string>
  <key>DTXcodeBuild</key>
  <string>6E35b</string>
  <key>IOKitPersonalities</key>
  <dict>
    <key>MyDriverTest3</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.apple.iokit.IOUSBFamily</string>
        <key>IOClass</key>
        <string>IOService</string>
        <key>IOProviderClass</key>
        <string>IOUSBDevice</string>
        <key>bcdDevice</key>
        <string>256</string>
        <key>idProduct</key>
        <integer>4369</integer>
        <key>idVendor</key>
        <integer>6631</integer>
      </dict>
  </dict>
  <key>OSBundleRequired</key>
  <string>Root</string>
</dict>
</plist>    

      

Below is the ioreg output for my storage device:

space pack@1a122000  <class IOUSBDevice, id 0x100001773, registered, matched, active, busy 0 (300 ms), retain 9>
+-o IOUSBCompositeDriver  <class IOUSBCompositeDriver, id 0x100001775, !registered, !matched, active, busy 0, retain 4>
 +-o IOUSBInterface@0  <class IOUSBInterface, id 0x100001776, registered, matched, active, busy 0 (293 ms), retain 8>
  +-o IOUSBMassStorageClass  <class IOUSBMassStorageClass, id 0x100001777, registered, matched, active, busy 0 (201 ms), retain 9>
   +-o IOSCSIPeripheralDeviceNub  <class IOSCSIPeripheralDeviceNub, id 0x100001779, registered, matched, active, busy 0 (99 ms), retain 7>
    +-o IOSCSIPeripheralDeviceType00  <class IOSCSIPeripheralDeviceType00, id 0x10000177a, !registered, !matched, active, busy 0 (13 ms), retain 9>
     +-o IOBlockStorageServices  <class IOBlockStorageServices, id 0x10000177d, registered, matched, active, busy 0 (13 ms), retain 6>
      +-o IOBlockStorageDriver  <class IOBlockStorageDriver, id 0x10000177e, registered, matched, active, busy 0 (12 ms), retain 47>
       +-o mophie SpacePack Media  <class IOMedia, id 0x100001784, registered, matched, active, busy 0 (12 ms), retain 11>
        +-o IOMediaBSDClient  <class IOMediaBSDClient, id 0x100001785, registered, matched, active, busy 0 (0 ms), retain 6>
         +-o IOFDiskPartitionScheme  <class IOFDiskPartitionScheme, id 0x100001788, !registered, !matched, active, busy 0 (1 ms), retain 6>
          +-o Untitled 1@1  <class IOMedia, id 0x10000178a, registered, matched, active, busy 0 (1 ms), retain 10>
           +-o IOMediaBSDClient  <class IOMediaBSDClient, id 0x10000178b, registered, matched, active, busy 0 (0 ms), retain 7>

      

Hope you can help me with this problem, many many thanks to this, I really appreciate your help!

+3


source to share


2 answers


Several points:

  • The no-kext approach should usually work for this kind of situations.
  • Typically, your code-behind kext will match (via IOProviderClass) IOUSBInterface

    , not IOUSBDevice

    . (for example see FTDI example )
  • The bundle id for IOService

    is com.apple.kpi.iokit

    , not com.apple.iokit.IOUSBFamily

    , although I suspect this shouldn't be a problem.
  • Is your code kext correctly signed and installed correctly? (I had instances where the kext in / Library / Extensions / did not work at boot time, at least on OSX 10.9.x, unlike System / Library / Extensions, although it should work fine for any devices with hot replacement.) Make sure the kext / identity cache is updated, in other words touch

    the Extensions directory whenever you update the kext.
  • What does he say kextutil -n

    ?
  • Have you tried setting a property IOKitDebug

    to see if your kext can get a device match?
  • Depending on how your firmware update commands are implemented, you can use ioctl

    node. You can send raw SCSI requests to SCSI devices via ioctl. I'm not sure if this will work for the USB mass storage class, but it will definitely work for USB attached SCSI (UAS) or any other "true" SCSI device. Obviously this only helps if your firmware update commands are displayed via SCSI.


If you are still stuck after all this, please provide additional information related to the above suggestions.

0


source


It looks like you are trying to use the low-level USB commands provided by IOUSBInterfaceInterface to connect to the USB mass storage interface and send some custom commands to update the firmware. Since this interface is advertised by Apple's mass storage drivers, you are probably not allowed to do so.

Instead, you can try making a second USB interface on your device, which is a vendor specific interface. You will be able to connect to this interface and send arbitrary control transfers to your device. Then your device will be a composite device if it didn't already exist.



Alternatively, you can try some kind of hack to send signals through the mass memory interface. For example, whenever a file with a special name is written to a device, it can be a signal that the device is entering bootloader mode to update the firmware.

0


source







All Articles