Skip to content
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

Implement usbh replug on pico #1193

Merged
merged 3 commits into from
Nov 30, 2021

Conversation

rppicomidi
Copy link
Contributor

This pull request resolves issue #1192 in my testing.

When I was debugging the issue, I found that the host could not send report requests because the endpoint was claimed already. The first commit implements hcd_device_close() more completely so the hardware does not think the endpoints are doing anything and the second commit clears the claimed and busy flags for the device endpoints.

I am very new to this project. Is directly clearing the claimed and busy flags safe?

@hathach hathach force-pushed the implement_usbh_replug_on_pico branch from fcaf272 to 3e3fe1e Compare November 30, 2021 10:38
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the PR. I have been busy with other works, and only have time to review this now. It is a great fix. host stack apparently needs more dev time. Though I found the while() with find_first loop is not sufficient. We are better with just 1 for loop to close endpoint.

Therefore I have update the PR (also rebased since master has several updates).

PS: confirmed that it fix #1192, probably fix issue raspberrypi/pico-sdk#483 as well.

Comment on lines 437 to 435
while (ep)
{
// in case it is an interrupt endpoint, disable it
usb_hw_clear->int_ep_ctrl = (1 << (ep->interrupt_num + 1));
usb_hw->int_ep_addr_ctrl[ep->interrupt_num] = 0;
// unconfigure the endpoint
ep->configured = false;
*ep->endpoint_control = 0;
*ep->buffer_control = 0;
hw_endpoint_reset_transfer(ep);
ep->dev_addr = ADDR_INVALID; // don't find this one again
ep = _hw_find_first_endpoint(dev_addr);
}
Copy link
Owner

@hathach hathach Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this loop is not sufficient, we should do only 1 for loop to close endpoint with matched address

PS: updated with latest push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants