首页 文章

USBInterfaceOpen始终报告kIOReturnExclusiveAccess错误

提问于
浏览
3

最近我头痛地遇到了这个问题,我已经在这个问题上花了一个星期,但仍然失败了 . 希望你能帮我把这块石头踢掉,非常感谢 .

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

我也试着写一个 codeless kext 来增加探测分数,但它仍然不知道我走错路,或者编写无代码kext有些错误,例如写错了IOClass,错误的捆绑ID .

我的无代码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>

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

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>

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

2 回答

  • 0

    几点:

    • 无代码kext方法通常适用于这种情况 .

    • 通常,您的无代码kext将匹配(通过IOProviderClass) IOUSBInterface ,而不是 IOUSBDevice . (例如见the FTDI example

    • 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是否有机会匹配该设备?

    • 根据实施固件更新命令的方式,您可以在设备节点上使用 ioctl . 您可以通过ioctl将原始SCSI请求发送到SCSI设备 . 我不确定这适用于USB海量存储类,但它绝对适用于USB连接SCSI(UAS)或任何其他"true" SCSI设备 . 显然,只有通过SCSI公开固件更新命令才有用 .

    如果完成所有这些,你仍然卡住了,请提供一些与上述建议相关的更多信息!

  • 0

    听起来您正在尝试使用IOUSBInterfaceInterface提供的低级USB命令连接到USB海量存储接口,并发送一些自定义命令来更新固件 . 由于Apple大容量存储驱动程序声明了该接口,因此您可能不允许这样做 .

    相反,您可以尝试在设备上创建第二个USB接口,这是供应商定义的接口 . 您将能够连接到该接口并将任意控制传输发送到您的设备 . 如果您的设备尚未使用,那么您的设备将成为复合设备 .

    或者,您可以尝试某种方式通过大容量存储接口发送信号 . 例如,每当将具有特殊名称的文件写入设备时,这可能是设备进入引导加载程序模式以进行固件更新的信号 .

相关问题