Hello,
I'm building the a usb keyboard for my OS, but I've met some problem when configuring the endpoint.
Code: https://github.com/fslongjin/DragonOS/b ... ci.c#L1613
My procedures are:
1. Get device descriptor (Line 1613)
2. Get the interface descriptor (Line 1744)
3. Get endpoint descriptor (Line 1748)
4. Set configuration with the value I retrieved from the config descriptor. (Line 1751)
5. Initialize the input_ep1 and create the input context, issue a "Configure Endpoint" command. (Line 1755)
In the first four steps, QEMU does not report errors, and it can also run normally on the physical machine. But the QEMU generates a 'CC_TRB_ERROR' TRB in the fifth step.
I check the "Configure Endpoint" TRB carefully, but I can't find anything wrong. I think, may be there are something wrong in the input context. I already checked the xhci spec and usb3.2 spec, but I don't know how to solve the problem.
So, what's wrong with my code?
Thank you!!!
XHCI: Error when configuring endpoint
Re: XHCI: Error when configuring endpoint
Did you send the Set Address command with the Block bit set? This is usually done quite a bit before you send the Configure Endpoint command.
If you have not, please read about the Set Address command. It is sent twice, once with the Block bit set and later with the Block bit cleared.
Ben
- https://www.fysnet.net/the_universal_serial_bus.htm
If you have not, please read about the Set Address command. It is sent twice, once with the Block bit set and later with the Block bit cleared.
Ben
- https://www.fysnet.net/the_universal_serial_bus.htm
Re: XHCI: Error when configuring endpoint
Hello, thanks for your reminder. Now I send set address twice, and I initialize the correct endpoint with the number from endpoint descriptor.BenLunt wrote:Did you send the Set Address command with the Block bit set? This is usually done quite a bit before you send the Configure Endpoint command.
If you have not, please read about the Set Address command. It is sent twice, once with the Block bit set and later with the Block bit cleared.
Ben
- https://www.fysnet.net/the_universal_serial_bus.htm
But, the qemu still report trb error…
Re: XHCI: Error when configuring endpoint
You forgot to set the Max Endpoint and Route string fields of the input context. Also don't know why you're messing with the output context, which is supposed to be managed by the controller.
Re: XHCI: Error when configuring endpoint
Hmm, what's the Max Endpoint field? I can't see it in the input context. Do you mean the Max Endpoint Service Time Interval Payload?Gigasoft wrote:You forgot to set the Max Endpoint and Route string fields of the input context. Also don't know why you're messing with the output context, which is supposed to be managed by the controller.
Re: XHCI: Error when configuring endpoint
Sorry, I mean "Context entries", which must be set to the highest numbered endpoint that you are configuring with the command. And bit 0 of the "Add" field should also be set to 1.
Re: XHCI: Error when configuring endpoint
Thank you very much! It works!Gigasoft wrote:Sorry, I mean "Context entries", which must be set to the highest numbered endpoint that you are configuring with the command. And bit 0 of the "Add" field should also be set to 1.