Design Article
Tell us What You Think
We want to know what you thought about this Design. Let us know by adding a comment.
Introduction to USB—Part VI
Christian Legare, Micrium
1/30/2013 2:36 PM EST
1-12 ENUMERATION
Enumeration is the process where the host configures the device and learns about the device’s capabilities. The host starts enumeration after the device is attached to one of the root or external hub ports.
Device enumeration follows these steps:
- Device Attachment
- Reset Device
- Get Device Descriptor
- Reset Device (again)
- Assign Address
- Get Configuration and Other Descriptors
- Select Device Driver
- Set Configuration
DEVICE ATTACHMENT
The host or hub detects the connection of a new device when a cable is connected between the host/hub port and the device. On first detection of the signal, the host/hub waits for at least 100ms, making sure the connector is inserted completely and power is not fluctuating on the device.
RESET DEVICE
The host then sends a USB Reset packet to the device to make sure the device is in a known state. While In this state, the device responds to the default address 0. Because of the master/slave nature of the protocol, one device is reset at a time. Thus, one device can respond to address 0.
GET DEVICE DESCRIPTOR
The next step is for the host to send a request to endpoint 0 of device address 0 to determine the maximum packet size. The Get Descriptor (Device) command is used for that purpose. There are a few requests like this one where the device must answer when using address 0.
RESET DEVICE (AGAIN)
The host resets the device a second time.
ASSIGN ADDRESS
At this stage, this is when a unique address will be assigned to the device using the Set Address request.
GET CONFIGURATION AND OTHER DESCRIPTORS
The following step is for the host to collect the remaining device information that will be used for the device configuration. The standard requests used are:
- Get Device Descriptor
- Get Configuration Descriptor
- Get String Descriptor
SELECT DEVICE DRIVER
At this stage, we start talking about device driver, because now that the host knows everything he needs to know about the device, it will start interacting with the device using the specific device driver.
SET CONFIGURATION
The Set Configuration request is then send to the device by the device driver. Even if from this point moving forward in time, the device is configured and can now perform the functions (classes) it is designed to do, it still is required to respond to standard requests.
Note: When writing a USB device driver for connecting to a Windows host, you may notice that the first request sent by the host has an unexpectedly large wLength of 64 bytes. The Windows host will then request a single IN packet, but will reset the device immediately, regardless of the value of the max packet length. The purpose of this transaction is to provide the Windows host with the packet size for all upcoming control transfers. That value is contained only in the first eight bytes of the IN packet. So, a reset after the first 8 bytes of the IN packet is not a problem on Windows. It is expected behavior.
Because the device stack may be confused after not being able to complete the transmission of all the 18 bytes of the device descriptor a second reset places the device in a known good state.
ENUMERATION FAILURE
According to the USB protocol specification, a host will attempt to read a descriptor three times when something is wrong with a descriptor. The three reads with be spaced with long pauses between requests. If it is not successful after the third attempt, the host reports an error with the device enumeration.Other cases of when a Host can decide to not enumerate a device are:
- If the appropriate driver for the device is not present in the host
- If the interface description does not match what the host can do
In these cases, the host should reset the bus or even power down the port (connector).
Next: USB Stacks
µC/USB Device: Universal Serial Bus Device Stack for the Renesas RX63N, Chapter 2, by Christian Legare, is excerpted with permission. The text is available at Micrium.

