zoukankan      html  css  js  c++  java
  • USB Mass Storage communication with PassThrough / more than 64K data length

    http://social.msdn.microsoft.com/Forums/windowsdesktop/zh-CN/35620a05-43be-46a8-8cbe-846bc8295d85/usb-mass-storage-cWe have an USB mass storage / Memory Stick device with an additional device on it. We communicate with PassThrough mechanism to the device. 

    Normally USB spec says that on USB level not more than 64K can
    send with one Bulk-Only-Transport (BOT) command to the device.
    On Win7 (and earlier) the mass storage driver has split the package
    automatically into smaller BOT packages if the original package
    has a volume of more than 64K.
     
    This is currently  not longer working on Win8.
    If I send an answer buffer length of more than 64k then the DeviceIoControl()
    was failing with error 87 (invalid Parameter).
    If I send an answer buffer less the 64K it is working.
    But I need a bigger buffer because our device can send more than 64K answer contents.

    Does anybody know why this was changed. 
    Is that behavior wanted and if yes, why?  
    Is that a bug? 
    THIS_SCSI_PASS_THROUGH_DIRECT sptd;
    memset(&sptd, 0, sizeof(THIS_SCSI_PASS_THROUGH_DIRECT));
    sptd.msptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
    ...
    sptd.msptd.DataTransferLength = cbData; // <<==== !!!
    sptd.msptd.DataBuffer = pData;
    // send receive command
    if ( !DeviceIoControl(hDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT,&sptd,
            sizeof(THIS_SCSI_PASS_THROUGH_DIRECT), &sptd,
            sizeof(THIS_SCSI_PASS_THROUGH_DIRECT), &cbRecvData, NULL))
    {
      // failed
      int nErrD= (int)wbs::SystemInfo::GetLastError();// error 87 (invalid parameter)

    There is a known problem in Win8 builds before 8320,
    where non-page aligned transfers fail for lengths falling
    within the range [(64K - 4K), 64K].

    The problem is fixed in builds 8320 or later.

    I'm not sure when a newer build will be generally available.
    In the meantime here are a few things to try.

    The following per-device setting can be used to
    increase the maximum transfer length from 64K to 128K,
    enabling IOCTL_SCSI_PASS_THROUGH_DIRECT to transfer
    more than 64K to the device.
    As an added bonus it may also increase general I/O throughput to the device.
    This setting is implemented on Windows Vista and above, 
    however use it with caution and thoroughly test with
    a particular device to ensure the device can tolerate this change.
    Some devices have been observed to have problems functioning properly
    when this setting is modified.

    With bit value 0x8 set on this DWORD registry value,
    USBSTOR increases the maximum transfer length reported
    for the specific device to 128KB. Otherwise the default value is 64KB.

    HKLMSystemCurrentControlSetControlusbstorVVVVPPPP
    DWORD: "DeviceHackFlags"

    Where “VVVV” represents the 4-digit USB Vendor ID for the device
    and “PPPP” represents the 4-digit Product ID.
    Leading 0’s are required. Restart the device
    (e.g. enable/disable or unplug/plug) for this setting to take effect.

    To obtain Vendor/Product ID for the device open device manager
    and select View -> Devices by connection.
    Right click on “USB Mass Storage Device”
    which is the parent of the recognized disk device.
    Then select Propertiesfrom the pop-up menu to bring up the Properties dialog.

    From the Properties dialog, select Details tab, then Hardware Idsproperty:

    Also in Windows 8, a larger maximum transfer length value
    is enabled by default for USB 3.0 mass storage devices.

    The problem seems to be solved with Windows 8 Build 8400.

  • 相关阅读:
    DirectX:在graph自己主动连线中增加自己定义filter(graph中遍历filter)
    C3P0数据库连接池使用
    POJ
    【jQuery】复选框的全选、反选,推断哪些复选框被选中
    BestCoder Round #75 King&#39;s Cake 模拟&amp;&amp;优化 || gcd
    《Javascript_Dom 编程艺术》(第2版)读书笔记
    POJ 2947-Widget Factory(高斯消元解同余方程式)
    MFC 小知识总结四
    迭代器和iter()函数
    hdu1595find the longest of the shortest 最短路
  • 原文地址:https://www.cnblogs.com/shangdawei/p/3164085.html
Copyright © 2011-2022 走看看