• 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.

  • 相关阅读:
    二分图大讲堂——彻底搞定最大匹配数(最小覆盖数)、最大独立数、最小路径覆盖、带权最优匹配
    POJ1469 COURSES
    HDU 1850 Being a Good Boy in Spring Festival(Nim博弈)
    取石子游戏(博弈)
    过山车(匈牙利算法)
    匈牙利算法与二分图
    HLG 1126 Final Destination II (转化为矩阵)(水题)
    快速幂与矩阵—>快速矩阵幂
    再论斐波那契数列(矩阵&快速幂)
    浮点数的陷阱--double i != 10 基本都是对的,不管怎么赋值
  • 原文地址:https://www.cnblogs.com/shangdawei/p/3164085.html
Copyright © 2020-2023  润新知