Skip to content

Instantly share code, notes, and snippets.

@Novakov
Created October 22, 2022 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Novakov/4b2d4094825b83ef58b23060224660f8 to your computer and use it in GitHub Desktop.
Save Novakov/4b2d4094825b83ef58b23060224660f8 to your computer and use it in GitHub Desktop.
Test report for libusb PR#1181

Libsub Late open

libusb/libusb#1181

Firmware 1

Composite device with several WinUSB devices (see descriptor below). WinUSB installed as driver using MSFT descriptors.

Test 1

Steps:

  1. Open device
  2. Claim interface 3
  3. Claim interface 2
  4. Perform control transfer to interface 2
  5. Release interface 2
  6. Release interface 3

Result:

  • Success
  • Device opened in step 2.
  • Device closed in step 6.

Test 2

Steps:

  1. Open device
  2. Claim interface 0
  3. Perform control transfer for interface 0
  4. Release interface 0

Result:

  • Success
  • Device opened in step 2.
  • Device closed in step 4.

Test 3

Steps:

  1. Open device
  2. Claim interface 4
  3. Perform control transfer for interface 4
  4. Release interface 4

Result:

  • Success
  • Device opened in step 2.
  • Device closed in step 4.

Test 4

Steps:

  1. Open device
  2. Claim interface 3
  3. Claim interface 2
  4. Perform control transfer for interface 2
  5. Release interface 2
  6. Release interface 3
  7. Claim interface 3
  8. Claim interface 2
  9. Perform control transfer for interface 2
  10. Release interface 2
  11. Release interface 3

Result:

  • Success
  • Device opened in steps 3. and 7.
  • Device closed in steps 6. and 11.

Test 5

Steps:

  1. Open device, no interface claimed
  2. Perform vendor control transfer

Result:

  • Success
  • Interface 0, auto-claimed and auto-released as part for control transfer
  • Device handle opened for auto-claim and closed after auto-release

Test 6

Steps:

  • Process1:
    • Opens device
    • Claims interface 0
    • Performs interface control transfer in loop
  • Process2
    • Opens device, no interface claimed
    • Perform vendor control transfer

Result:

  • Success
  • Libusb attempted to claim interface 0 as part of control transfer
    • Failed as it is in use
  • Interface 1, auto-claimed and auto-released as part for control transfer
  • Device handle opened for auto-claim and closed after auto-release

Descriptor

Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0xEF
bDeviceSubClass:      0x02
bDeviceProtocol:      0x01
bMaxPacketSize0:      0x40 (64)
idVendor:           0x4D4E
idProduct:          0x4455
bcdDevice:          0x2100
iManufacturer:        0x01
0x0409: "Novakov"
iProduct:             0x02
0x0409: "Double WinUSB"
iSerialNumber:        0x03
0x0409: "123456"
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x15
Open Pipes:              0

Configuration Descriptor:
wTotalLength:       0x003E
bNumInterfaces:       0x05
bConfigurationValue:  0x01
iConfiguration:       0x00
bmAttributes:         0x80 (Bus Powered )
MaxPower:             0xFA (500 Ma)

Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x00
bInterfaceClass:      0xFF
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x00

Unknown Descriptor:
bDescriptorType:      0x0B
bLength:              0x08
08 0B 01 03 FF 41 00 04 

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x00
bNumEndpoints:        0x00
bInterfaceClass:      0xFF
bInterfaceSubClass:   0x31
bInterfaceProtocol:   0xFF
iInterface:           0x00

Interface Descriptor:
bInterfaceNumber:     0x02
bAlternateSetting:    0x00
bNumEndpoints:        0x00
bInterfaceClass:      0xFF
bInterfaceSubClass:   0x32
bInterfaceProtocol:   0xFF
iInterface:           0x00

Interface Descriptor:
bInterfaceNumber:     0x03
bAlternateSetting:    0x00
bNumEndpoints:        0x00
bInterfaceClass:      0xFF
bInterfaceSubClass:   0x33
bInterfaceProtocol:   0xFF
iInterface:           0x00

Interface Descriptor:
bInterfaceNumber:     0x04
bAlternateSetting:    0x00
bNumEndpoints:        0x00
bInterfaceClass:      0xFF
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x05
0x0409: "Third device"

Firmware: CDC

CDC-device with two interfaces. libusb-win32 installed as filter driver.

Test 1

Steps:

  1. Open device
  2. Claim interface 0
  3. Claim interface 1
  4. Perform control transfer on interface 1
  5. Release interface 1
  6. Release interface 0

Result:

  • Partial success
  • Control transfer itself failed
    • Probably due to libusb/libusbK setup - libusbK tools also have problems performing transfers
  • Device handle opened in step 2.
  • Device handle closed in step 6.

Descriptor

Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0x02
bDeviceSubClass:      0x02
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x40 (64)
idVendor:           0x4D4E
idProduct:          0x5350
bcdDevice:          0x0200
iManufacturer:        0x01
0x0409: "Novakov"
iProduct:             0x02
0x0409: "Single CDC"
iSerialNumber:        0x03
0x0409: "123456"
bNumConfigurations:   0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     Full
Device Address:       0x17
Open Pipes:              3

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:            0xFF

Endpoint Descriptor:
bEndpointAddress:     0x02  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0xFF

Endpoint Descriptor:
bEndpointAddress:     0x82  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0xFF

Configuration Descriptor:
wTotalLength:       0x004B
bNumInterfaces:       0x02
bConfigurationValue:  0x01
iConfiguration:       0x00
bmAttributes:         0x80 (Bus Powered )
MaxPower:             0xFA (500 Ma)

Unknown Descriptor:
bDescriptorType:      0x0B
bLength:              0x08
08 0B 00 02 02 02 00 04 

Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x01
bInterfaceClass:      0x02
bInterfaceSubClass:   0x02
bInterfaceProtocol:   0x00
iInterface:           0x00

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x05
05 24 00 10 01 

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x05
05 24 01 00 03 

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x04
04 24 02 02 

Unknown Descriptor:
bDescriptorType:      0x24
bLength:              0x05
05 24 06 02 03 

Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:            0xFF

Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0x0A
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x00

Endpoint Descriptor:
bEndpointAddress:     0x02  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0xFF

Endpoint Descriptor:
bEndpointAddress:     0x82  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0040 (64)
bInterval:            0xFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment