View Full Version : Regarding USB Enumeration

07-21-2009, 04:26 PM

I need to know something about the process which happens when we immediately insert a new USB device into our computer.

For example, if I connect my DSLR via USB, I get a pop-up in Windows saying "Canon EOS 350D".

I want to know which data structure holds this piece of info? Is it just a string in the firmware or is it some VID/PID combination for which Windows already has a look-up table sort of thing to pull out this string?


07-21-2009, 04:43 PM
USB standard defines something called descriptors like configuration descriptor, device descriptor, end-point descriptor etc.
These descriptor also hold vendor & product strings apart from vendor id and product id.
For more details read chapter 9 of USB specs.

On windows, if you go to device-manager -> USB devices and then double-click on your device. Look at the last tab (don't reme,mber its name). There you will have a drop-down combo box which will show you lot of device-specific info.

On Linux, you can use "lsusb -v" or write a simple program using libusb to dump the descriptors.

07-21-2009, 05:02 PM
@devpriya: I recommend that you read the USB Documentation (clickie) (http://www.usb.org/developers/docs/) for real details regarding this.

However, to answer your query, the enumeration process involves sending of the USB_CONFIG_DESCRIPTOR, which essentially contains information regading the endpoints, device class, buffer size and length of the following descriptors. This is always fixed in size (number of bytes) and while it is different for different device, always adheres to the same number of bytes in length, i.e 32 bytes. Also, this is compulsory, and there can be multiple USB_CONFIG_DESCRIPTORs for devices which support multiple configurations.

The USB_CONFIG_DESCRIPTOR(s) are followed by the USB_NUM_INTERFACES data. There can be multiple interfaces in each configuration. This is a simple number (>0 and <256) which specifies the number of interfaces in each configuration. One each is sent for each configuration. (so if you have 2 configurations having 3 and 8 interfaces respectively, then you will simply physically send the numbers 3 and 8 ).

The USB_CONFIG_DESCRIPTOR is followed by the USB_DEVICE_DESCRIPTOR. This tells the host about the device i.e the USB version (typically 0=USB1.0, 1=USB1.1 or 2=USB2.0), the class code, the protocol code (both are generally kept 0xFF to specify "user-defined"), Maximum endpoint packet length, VID, PID, Device firmware version, device serial number. (the last three are optional, this is defined by the first byte sent, which is the length of the following descriptor).

The USB_DEVICE_DESCRIPTOR is followed by the USB_STRING_DESCRIPTOR, this is where you specify some user-friendly text to describe your device (like you said "Canon EOS 350D"). This is specified to the host by sending the length of the string index, followed by the encoding (3=US-English, which is most typically used), followed by the sizes and ASCII character based strings of the Vendor Name and Product Name. This is optional, you can send a 0 for the length of the string index and get away with it all together.

The last part, i.e the USB_STRING_DESCRIPTOR can be overwritten in windows, i.e you can choose to show any text you wish if you make an inf file to support your driver. The %strkey% section of the INF file can contain any string that you want to show (this is used when a proprietary USB hardware is used and the developer has no control over the strings).

Hope this clears your doubts.


Debu :)

07-21-2009, 08:27 PM
Debu thanks for enlighting us all with precise info.....