Skip to content

Implement usbh replug on pico#1193

Merged
hathach merged 3 commits intohathach:masterfrom
rppicomidi:implement_usbh_replug_on_pico
Nov 30, 2021
Merged

Implement usbh replug on pico#1193
hathach merged 3 commits intohathach:masterfrom
rppicomidi:implement_usbh_replug_on_pico

Conversation

@rppicomidi
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@hathach hathach merged commit 6af58e3 into hathach:master Nov 30, 2021
7FM pushed a commit to 7FM/tinyusb that referenced this pull request Aug 23, 2025
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