Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Windows USB HID driver questions

Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

I have two questions related to Windows USB HID driver. Hopefully the experts here can shed some light. Thanks in advance.

Reference discussion:
https://github.com/libusb/hidapi/issues/274

Question 1: I am puzzled why I have not seen any USB High Speed HID device with the Interrupt IN/OUT Endpoints' wMaxPacketSize > 64 Bytes.

Does Windows inbox USB HID driver support High Speed USB HID device with the Interrupt IN/OUT Endpoints' wMaxPacketSize > 64 Bytes? If the answer is NO, what is the reason? If yes, does it support high bandwidth Interrupt Endpoint?

Question 2: Does the following limitation of Hidclass/Hidparse driver pair put a hard limit of HID device' Input, Output, and Feature Reports to be 8KB even though the underline transport (USB, Bluetooth, BLE, I2C, SPI) supports up to 64 KB?
https://learn.microsoft.com/en-us/windows-hardware/drivers/hid/hid-transports

The Hidclass/Hidparse driver pair defines lengths of HID Input, Output, and Feature Reports. The limit is 8 KB (minus 1 bit). Even if a HID minidriver can request a transfer of more than 8 KB for a report, only reports smaller than 8 KB are successfully transferred.

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,563

    Q1: It's because of the H in HID. When humans are involved, there's rarely a need for high bandwidth. We just aren't that quick.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    @Tim_Roberts said:
    Q1: It's because of the H in HID. When humans are involved, there's rarely a need for high bandwidth. We just aren't that quick.

    Probably true for last time. Now HID is used quite widely. You may want to take a look at this discussion:
    https://github.com/Yubico/libfido2/issues/335

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    I found one potential answer to the first question but I am not so sure if it is still relevant or not as the post was more than 8 years ago.

    Ref: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/413867/usb---high-speed-degredation

    As of HID interrupt IN/OUT endpoints,

    In the default interface after high-speed enumeration, interrupt endpoint should have 64 bytes (or less) MPS (Max Packet Size, bMaxPacketSize) on the endpoint descriptor. Greater MPS should be placed in an alternate interface. Unfortunately, the in-box HID drivers of Windows/Linux don't provide any way to send Set_Interface to HID device, to switch to an alternate interface. And then, the max transfer speed under the in-box HID drivers is limited to

    64 bytes/transaction x 1 transaction/micro-frame x 8000 micro-frames/sec

    = 512,000 bytes/sec

    You may get more speed over the default endpoint (ie. Set_/Get_Report) than interrupt endpoints. The MPS of the default endpoint is also 64 bytes, but two or more transactions are allowed per micro-frame.

    Tsuneo

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258
    edited May 14

    As for high bandwidth high speed Interrupt Endpoint (not limited to USB HID device), it was reported that Windows XP/Vista/7 do not support that. I am not so sure if later version of Windows like 8/8.1/10/11 support this or not.

    Reference from this forum.
    https://community.osr.com/discussion/161236/high-bandwidth-usb-2-0-endpoints

    XP is confirmed not to support this feature as per Cypress KB as well (now part of Infineon).
    https://community.infineon.com/t5/Knowledge-Base-Articles/High-Bandwidth-Interrupt-Transfers-Three-Packets-per-Microframe-in-Windows-XP/ta-p/250912

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258
  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    I am also playing at the FX2HID example from Jan Axelson, using a Cypress (now part of Infineon) EZ-USB FX2LP breakout board.
    http://janaxelson.com/hidpage.htm

    I modified the wMaxPacketSize of the Interrupt IN/OUT endpoint and the HID IN/OUT report size to 128 Bytes. The FW is not fully working yet but at least Windows 10/11 can enumerate the device.

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    There is one more confirmation here with wMaxPacketSize of the Interrupt IN/OUT Endpoint to be 512 Bytes. And this device MIcrochip Power Debugger should work under Windows 7 onward (not so sure about Windows XP and Vista).

    https://github.com/libusb/hidapi/issues/274#issuecomment-1547861126

    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              4 Power Debugger CMSIS-DAP
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      35
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
    
  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    Reference:
    https://github.com/libusb/hidapi/issues/478#issuecomment-1550841201

    I have used Jan Axelson's FX2HID example and Cypress' Bulkloop example and created high speed USB HID devices with Interrupt IN/OUT endpoint with wMaxPacketSize = 512 Bytes and it seems to work fine under Windows 10/11.

    So I think the answer is clear for Windows 7/10/11. I have no idea about Windows XP SP2 and Windows Vista but anyway I do not care about them.

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    As for high bandwidth high speed Interrupt Endpoint (not limited to USB HID device), it was reported that Windows XP/Vista/7 do not support that. I am not so sure if later version of Windows like 8/8.1/10/11 support this or not.

    It seems to me that Windows seems to support wMaxPacketSize = 3072 bytes for High Speed USB device but there may be a limit for the bInerval value.

    The following device with bInterval = 1 enumerates successfully under Ubuntu Linux 20.04 but not Windows 11 (same laptop, dual boot). The error says that there are not enough system resource. It is a simple mod of Cypress BulkLoop FW. Once I change bInterval to 2, then it can enumerate under Windows 11.
    `
    [email protected]:~$ lsusb -vvv -d 04b4:1004

    Bus 003 Device 002: ID 04b4:1004 Cypress Semiconductor Corp. EZ-USB
    Device Descriptor:
    bLength 18
    bDescriptorType 1
    bcdUSB 2.00
    bDeviceClass 0
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 64
    idVendor 0x04b4 Cypress Semiconductor Corp.
    idProduct 0x1004
    bcdDevice 0.00
    iManufacturer 1 Cypress
    iProduct 2 EZ-USB
    iSerial 0
    bNumConfigurations 1
    Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 0x0020
    bNumInterfaces 1
    bConfigurationValue 1
    iConfiguration 0
    bmAttributes 0x80
    (Bus Powered)
    MaxPower 100mA
    Interface Descriptor:
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 0
    bAlternateSetting 0
    bNumEndpoints 2
    bInterfaceClass 255 Vendor Specific Class
    bInterfaceSubClass 0
    bInterfaceProtocol 0
    iInterface 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x02 EP 2 OUT
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x1400 3x 1024 bytes
    bInterval 1
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x86 EP 6 IN
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x1400 3x 1024 bytes
    bInterval 1
    Device Qualifier (for other device speed):
    bLength 10
    bDescriptorType 6
    bcdUSB 2.00
    bDeviceClass 0
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 64
    bNumConfigurations 1
    can't get debug descriptor: Resource temporarily unavailable
    Device Status: 0x0000
    (Bus Powered)
    `

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258
    edited May 20

    As for high bandwidth high speed Interrupt Endpoint (not limited to USB HID device), it was reported that Windows XP/Vista/7 do not support that. I am not so sure if later version of Windows like 8/8.1/10/11 support this or not.

    It seems to me Windows 10 and Windows 11 do support high bandwidth Interrupt IN/OUT endpoint. I have modified Cypress' BulkSrcSink example to IntrSrcSink with high bandwidth endpoint (using either Cypress driver or WinUSB driver). However, I am not able to get bInterval=1 for both the IN/OUT endpoint, only one of them. Windows complains that resource is not available

    And the Interrupt IN endpoint does not seem to be able to achieve the 24MB/sec bandwidth. Only the Interrupt OUT endpoint can do that.

    Cypress CyStream bandwidth measurement for the OUT endpoint when bInterval=1

    Cypress CyStream bandwidth measurement for the IN endpoint when bInterval=1

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    For those who have the Cypress EZ-USB FX2LP boards, you can check out the FW here. Take note I am not a software/firmware developer so the modification may not be totally correct. Comments welcome. Thanks.

    1) High Speed USB HID device
    https://github.com/libusb/hidapi/issues/478

    2) High bandwidth Interrupt IN/OUT Endoint (not USB HID Device)
    https://github.com/mcuee/libusbk/issues/48

  • Xiaofan_ChenXiaofan_Chen Member - All Emails Posts: 258

    And the Interrupt IN endpoint does not seem to be able to achieve the 24MB/sec bandwidth. Only the Interrupt OUT endpoint can do that.

    This seems to be a FW implementation issue. Once I use CyStream FW as the base and change ISOC endpoints to Interrupt endpoints, I can get the expected results for both Interrupt IN and OUT endpoint (at about 24Mbps).

    Reference test results: using libusbK kList/kBench application. Same results from Cypress CySteam host application.
    https://github.com/mcuee/libusbk/issues/48#issuecomment-1556459721

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 19-23 June 2023 Live, Online
Writing WDF Drivers 10-14 July 2023 Live, Online
Kernel Debugging 16-20 October 2023 Live, Online
Developing Minifilters 13-17 November 2023 Live, Online