</>EmbeddedInterview

What happens during USB enumeration?

HardCommunication Protocols

Short answer: When a device is plugged in, the host detects it, resets it, reads its device descriptor at address 0 to learn the control endpoint's maximum packet size, assigns it a unique address, reads all its descriptors (device, configuration, interfaces, endpoints, strings), chooses a driver based on class or vendor/product ID, and selects a configuration. Only then can the device's other endpoints be used.

Step by step

  1. Attach: the device connects a pull-up on D+ (full/high speed) or D− (low speed); the host sees the line change.
  2. Reset: the host drives SE0 for at least 10 ms; a high-speed-capable device performs the chirp handshake to switch to 480 Mbps.
  3. GET_DESCRIPTOR (device) to address 0, often only the first 8 bytes, to learn bMaxPacketSize0.
  4. SET_ADDRESS: the device must switch to the new address after the status stage of this request (a common firmware bug).
  5. GET_DESCRIPTOR (device) again (full 18 bytes): VID, PID, class, number of configurations.
  6. GET_DESCRIPTOR (configuration): first 9 bytes for wTotalLength, then the full configuration with all interface and endpoint descriptors.
  7. String descriptors (manufacturer, product, serial number), optionally.
  8. Driver binding: the host OS matches class/subclass/protocol or VID/PID to a driver.
  9. SET_CONFIGURATION: the device becomes "configured" and its endpoints active. Class-specific requests follow (e.g. HID report descriptor, CDC line coding).

Common failure causes

  • Descriptor errors (wrong lengths, wTotalLength mismatch, wrong endpoint addresses).
  • Slow responses to control requests (the host has timeouts, e.g. 500 ms for some stages).
  • Wrong USB clock accuracy (full speed needs ±0.25%; internal RC oscillators need clock recovery via SOF packets).
  • Missing pull-up or VBUS sensing configuration.

Debugging: dmesg and lsusb -v on Linux, USBView on Windows, Wireshark with usbmon, or a hardware USB protocol analyser.