USBInterfaceOpen 总是报 kIOReturnExclusiveAccess 错误 [英] USBInterfaceOpen always report kIOReturnExclusiveAccess error

查看:43
本文介绍了USBInterfaceOpen 总是报 kIOReturnExclusiveAccess 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近遇到这个问题很头疼,我已经在这个问题上花了一个星期,但还是失败了.希望你能帮我把这块石头踢开,非常感谢.

Recently I encountered this problem headachely, I've already spend one week on this issue, but still failed. Hopefully, you can help me to kick this stone away, many thanks.

我的问题:我们公司为iPhone生产USB存储设备,这个存储设备实际上有一个SDCard.现在,我们要开发一个 Mac 应用程序来更新此存储设备的固件.但是每次我将存储设备连接到 Mac 时,Mac 都会自动挂载它,并且在调用 USBInterfaceOpen 时总是以 kIOReturnExclusiveAccess 失败.

My Problem: Our compony produce USB storage device for iPhone, actually there is a SDCard in this storage device. Now, we want to develop an Mac app to update firmware for this storage device. But every time I connect the storage device to Mac, Mac mounts it automatically, and I always fails with kIOReturnExclusiveAccess when invoke USBInterfaceOpen.

我也尝试写一个无代码kext来增加探测分数,但它仍然不起作用.不知道是我走错了路,还是写了无代码kext的一些错误,例如,写了一些错误的IOClass,错误的bundle ID.

I also try to write a codeless kext to increase the probe score, but it still doesn't work. I don't know wether I go a wrong way, or some mistakes for writing the codeless kext, eg, write some wrong IOClass, wrong bundle ID.

我的无代码 kext info.plist 是:

My codeless kext info.plist is:

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

以下是 ioreg 对我的存储设备的结果:

Below is the result from ioreg 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>

希望你能帮助我解决这个问题,非常感谢,非常感谢你的帮助!

Hopefully you can help me on this problem, many many many thanks, I preciate your help very much!

推荐答案

几点:

  • 无代码 kext 方法通常适用于这种情况.
  • 通常,您的无代码 kext 将匹配(通过 IOProviderClass)IOUSBInterface,而不是 IOUSBDevice.(例如,请参阅FTDI 示例)
  • IOService 的包标识符是 com.apple.kpi.iokit,而不是 com.apple.iokit.IOUSBFamily,虽然我怀疑这应该不是问题.
  • 您的无代码 kext 是否已正确签名和安装?(我遇到过这样的情况,/Library/Extensions/中的 kext 在启动时不起作用,至少在 OSX 10.9.x 上,与/System/Library/Extensions 不同,尽管它对于任何热插拔设备都应该可以正常工作.)确保 kext/personality 缓存是最新的,换句话说,每当您更新 kext 时,touch 扩展目录.
  • kextutil -n 说什么?
  • 您是否尝试过设置 IOKitDebug 个性属性,看看你的 kext 是否有机会匹配设备?
  • 根据您的固件更新命令的实施方式,您可以在设备节点上使用 ioctls.您可以通过 ioctl 向 SCSI 设备发送原始 SCSI 请求.我不确定这是否适用于 USB 大容量存储类,但它肯定适用于 USB 连接的 SCSI (UAS) 或任何其他真正的"SCSI 设备.显然,这仅在您的固件更新命令通过 SCSI 公开时才有帮助.
  • The codeless kext approach should normally work for this kind of situation.
  • Typically, your codeless kext would match (via IOProviderClass) an IOUSBInterface, not an IOUSBDevice. (e.g. see the FTDI example)
  • The bundle identifier for IOService is com.apple.kpi.iokit, not com.apple.iokit.IOUSBFamily, although I suspect that shouldn't be an issue.
  • Is your codeless kext signed and installed correctly? (I have had instances where a kext in /Library/Extensions/ would not work at boot time, at least on OSX 10.9.x, unlike /System/Library/Extensions, although it should work OK for any hot-plugged devices.) Make sure the kext/personality cache is up to date, in other words, touch the Extensions directory whenever you update the kext.
  • What does kextutil -n say?
  • Have you tried setting the IOKitDebug personality property to see if your kext is even getting a chance to match the device?
  • Depending on how your firmware update commands are implemented, you may be able to use ioctls on the device node. You can send raw SCSI requests to SCSI devices via ioctl. I'm not sure this will work for the USB mass storage class, but it definitely will for USB attached SCSI (UAS) or any other "true" SCSI device. Obviously this only helps if the your firmware update commands are exposed via SCSI.

如果在这一切之后,您仍然被卡住,请提供与上述建议相关的更多信息!

If after all of that, you're still stuck, please provide some more information related to the above suggestions!

这篇关于USBInterfaceOpen 总是报 kIOReturnExclusiveAccess 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆