OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:48 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: XHCI: Error when configuring endpoint
PostPosted: Wed Sep 28, 2022 5:45 am 
Offline

Joined: Thu Aug 25, 2022 7:28 am
Posts: 12
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!!!


Top
 Profile  
 
 Post subject: Re: XHCI: Error when configuring endpoint
PostPosted: Wed Sep 28, 2022 4:56 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
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


Top
 Profile  
 
 Post subject: Re: XHCI: Error when configuring endpoint
PostPosted: Wed Sep 28, 2022 8:47 pm 
Offline

Joined: Thu Aug 25, 2022 7:28 am
Posts: 12
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…


Top
 Profile  
 
 Post subject: Re: XHCI: Error when configuring endpoint
PostPosted: Wed Sep 28, 2022 9:49 pm 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: XHCI: Error when configuring endpoint
PostPosted: Thu Sep 29, 2022 3:08 am 
Offline

Joined: Thu Aug 25, 2022 7:28 am
Posts: 12
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?


Top
 Profile  
 
 Post subject: Re: XHCI: Error when configuring endpoint
PostPosted: Thu Sep 29, 2022 3:33 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: XHCI: Error when configuring endpoint
PostPosted: Fri Sep 30, 2022 5:35 am 
Offline

Joined: Thu Aug 25, 2022 7:28 am
Posts: 12
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Kamal123 and 83 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group