First of all, I assume by
GET_CONFIG you mean
bDescriptorType = 1 (DEVICE).
The Device descriptor length is indeed 0x12 bytes and that value does not change within the descriptor (
/* USB Standard Device Descriptor */
uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] =
0x12, /*bLength */
0x00, /*bcdUSB */
0xef, /*bDeviceClass: Misc */
LOBYTE(0x0250), /*bcdDevice (2.50) */
HIBYTE(0x0250), /*bcdDevice (2.50) */
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
USBD_IDX_PRODUCT_STR, /*Index of product string*/
USBD_IDX_SERIAL_STR, /*Index of serial number string*/
} ; /* USB_DeviceDescriptor */
However during enumeration the Host may not request more than 8 bytes at first, because it does not yet know the maximum transfer length for endpoint 0 (
bMaxPacketSize0). Why 8 bytes? Because the eighth byte in the Device descriptor is exactly
bMaxPacketSize0 and also it’s the minimum value for
bMaxPacketSize0 for FS USB.
So, the usual sequence to get device descriptor looks like this:
- GET_DESCRIPTOR(1) wLength = 0x08 (which may also be set to 0x40 - maximum, but devices usually reply with only 8 bytes)
- Learn device
bLength of Device descriptor
bMaxPacketSize0 is configured on the Host controller for EP0 of the device (somehow; I’m not too familiar with USB Host Controllers)
- (I believe a RESET is usually sent here)
- GET_DESCRIPTOR(1) (depending on
bMaxPacketSize0 this might be split into several transactions)
- A full device descriptor is returned
Also, it’s within spec of USB that the device may respond with less data than requested in wLength field of SETUP packet, since the host may only specify the maximum transfer length.
Again, this is all written in context of Full Speed USB.