I'm working on xhci controller driver for a proprietary OS. I'm having a problem with enumerating USB2 devices. USB3 devices get enumerated without issues. Here's what my driver does:
- Attach device and a port status change event is posted.
- if the event is a USB2 attach, reset the port and wait for it to complete the reset.
- Send an
enableSlot
command to the controller. - if success, send an
AddressDevice
command to the controller. - If success, read the device descriptor and get the
maxPacketSize
- Update the input context and send an
EvaluateContext
command. - If success, read the configuration descriptor.
- Configure contexts, send
ConfigureEndpoint
command to the controller. - If success, send a
SET_CONFIGURATION
request to the device. - Device responds with a transfer event with a
success
completion code.
Now, if I attach a USB3 device, all 10 steps complete without issues.
However, if I attach a USB2 device, only the first 9 steps complete and the device responds with a STALL
on the 10th step.
I have tried more things than I can even list here, including playing with the BSR, sending SET_ADDRESS requests manually, trying other configurations, different devices, sending wrong configurations... They all return a STALL on the status stage trb.
Is there any way to know what is causing the usb2 devices to stall? How can I fix this? Any pointers are much appreciated.