-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dcd_da146xx: Implement dcd_edpt_close_all() #1096
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also reset the xfer_ctl_t xfer_status[EP_MAX][2];
(except EP0) as well. Since the new configure may have less endpoint than the one we are closing.
Note: for multiple configuration , SET_CONFIG can be set without an bus_reset.
@hathach thanks for input, I will update PR. But since you are on this, let me ask about something that prevents USB3CV tests to pass on this board.
It looks like USB3CV during test queries about device descriptors with request size 8 at the beginning, Have you tried running different board (like STM32F4, that are now configured for EP0 size 64) to have EP0 size 8 to I'm not familiar with USB spec so I'm not sure if USB3CV is wrong or TinyUSB. |
@kasjer this is really an edge case. This particular code is added since it is needed when testing with actual host driver such linux/windows with 8-byte control endpoint e.g msp430. The host driver won't bother getting the 2nd packet EP0 and will send ZLP as status right after the 1st packet. Maybe the USBCV has different expectation, I will try to test it later on. You can try to comment it out to run the USBCV, but you may have issue with normal enumeration. |
a9d1eb2
to
1927a31
Compare
@hathach I decided to make dcd_edpt_close_all() look very simple. |
Unconditionally disables all endpoints except EP0.
1927a31
to
fbac58e
Compare
@hathach about USB3CV and Windows/Linux enumeration difference. But there is simpler solution that can make USB3CV and Windows happy. if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed &&
((tusb_control_request_t*) p_request)->wLength > sizeof(tusb_desc_device_t)) // <---- New condition
{
len = CFG_TUD_ENDPOINT0_SIZE;
// Hack here: we modify the request length to prevent usbd_control response with zlp
((tusb_control_request_t*) p_request)->wLength = CFG_TUD_ENDPOINT0_SIZE;
} USB3VC when requests device descriptor in non-addressed state asks for exactly 18 bytes (descriptor size). You may consider this new condition that will only affect boards with small EP0 size. I will not insist, but it was quite I did not checked Mac behavior though. |
The previous edpt_close_all() is actually simpler since it is used when expecting a full reconfiguration. The edpt_close() is currently meant for ISO only, in the future, I plan to retire/remove it to prefer and better API e.g edpt_resize() due to the fact that close/reopen does not work well with some MCUs. But I am ok if you still prefer to keep it this way though. |
I looked simpler but it was missing stuff that you mentioned in previous comment. |
@kasjer the new condition look great. IMHO, It is really OS host driver fault, getting the 1st 8bytes (wLength = 8) to get EP0 size is common approach similar to getting first 9 bytes of configuration descriptor. I did this as well in the host stack https://github.com/hathach/tinyusb/blob/master/src/host/usbh.c#L712 Back to your suggestion, I think it is great, could you made an PR for it along with the comment to explain the different between the 2 cases
I will try to check with msp430 and macOS on my side. That is the port that requires this condition to work with. #184 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked simpler but it was missing stuff that you mentioned in previous comment.
dcd_edpt_close() is still missing that part but I already have code ready for PR that does xfer cleanup there.
Look good, thank you for your PRs.
PS: esp32s2 failed due to unrelated issue, I will check it out.
Describe the PR
Unconditionally disables all endpoints except EP0.
Related to #1059
Additional context
Not tested yet with USBCV