5

I'm developing a C app using libusb-1.0. I want to get some config parameters related to usb devices. My question is related to bcdUSB parameter. My code is like following:

libusb_device *dev;
struct libusb_device_descriptor desc;

....

ret = libusb_get_device_descriptor(dev, &desc);

if (ret<0) {
    fprintf(stderr, "error in getting device descriptor\n");
    return 1;
}

printf("bcdUSB: %04x\n", desc.bcdUSB);

For some devices I get 0401 value:

bcdUSB: 0401

I don't understand what's exactly the meaning of this value.

In libusb code I found this comment in libusb_device_descriptor structure code:

/** USB specification release number in binary-coded decimal. A value of
 * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. */
uint16_t bcdUSB;

It specifies just 0200 and 0110 values meaning. Is there a documentation of all possible values of bcdUSB including 0401 ?

Kallel Omar
  • 1,208
  • 2
  • 17
  • 51

2 Answers2

2

I am unaware about any documentation with all possible values of bcdUSB being described, yet have to mention one thing. Nothing prevents a USB device from sending an invalid device descriptor content. Although, i didn't exactly test it on anything, it seems quite likely to me an OS is going to ignore a wrong bcdUSB, with the device continuing to operate as expected.

Make sure to have some sane defaults, just in case of encountering an invalid value there.

Just to demonstrate, this is how a device descriptor is defined on a device side. Pretty much "hardcoded". And yea, this is an actual code, from an actual lib, running on an actual device.

/*-----------------------------------------------------------------------------+
| Device Descriptor 
|-----------------------------------------------------------------------------*/
uint8_t const abromDeviceDescriptor[SIZEOF_DEVICE_DESCRIPTOR] = {
    SIZEOF_DEVICE_DESCRIPTOR,               // Length of this descriptor
    DESC_TYPE_DEVICE,                       // Type code of this descriptor
    0x00, 0x02,                             // Release of USB spec
    0x02,                                   // Device's base class code
    0x00,                                   // Device's sub class code
    0x00,                                   // Device's protocol type code
    EP0_PACKET_SIZE,                        // End point 0's packet size
    USB_VID&0xFF, USB_VID>>8,               // Vendor ID for device, TI=0x0451
                                            // You can order your own VID at www.usb.org"
    USB_PID&0xFF, USB_PID>>8,               // Product ID for device,
                                            // this ID is to only with this example
    VER_FW_L, VER_FW_H,                     // Revision level of device
    1,                                      // Index of manufacturer name string desc
    2,                                      // Index of product name string desc
    USB_STR_INDEX_SERNUM,                   // Index of serial number string desc
    1                                       //  Number of configurations supported
};
Boris Lipschitz
  • 1,514
  • 8
  • 12
1

I don't know of any restrictions on the valid release numbers, but numbers like 1.1 for USB FS or 2.0 for USB HS (0x0200 and 0x0110 in BCD respectively) are the typical values I've seen. Some other possible values can probably be gleaned from this article: https://www.tomshardware.com/features/usb-decoded-all-the-specs-and-version-numbers