XHCI: Error when configuring endpoint

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
longjin
Posts: 12
Joined: Thu Aug 25, 2022 7:28 am
Libera.chat IRC: longjin

XHCI: Error when configuring endpoint

Post by longjin »

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!!!
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: XHCI: Error when configuring endpoint

Post by BenLunt »

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
longjin
Posts: 12
Joined: Thu Aug 25, 2022 7:28 am
Libera.chat IRC: longjin

Re: XHCI: Error when configuring endpoint

Post by longjin »

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
Hello, thanks for your reminder. Now I send set address twice, and I initialize the correct endpoint with the number from endpoint descriptor.
But, the qemu still report trb error…
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: XHCI: Error when configuring endpoint

Post by Gigasoft »

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.
longjin
Posts: 12
Joined: Thu Aug 25, 2022 7:28 am
Libera.chat IRC: longjin

Re: XHCI: Error when configuring endpoint

Post by longjin »

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.
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
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: XHCI: Error when configuring endpoint

Post by Gigasoft »

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.
longjin
Posts: 12
Joined: Thu Aug 25, 2022 7:28 am
Libera.chat IRC: longjin

Re: XHCI: Error when configuring endpoint

Post by longjin »

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.
Thank you very much! It works!
Post Reply