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

fix(usbh): robustness against unplugging usb device when it is busy #2205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abakosh
Copy link

@abakosh abakosh commented Aug 4, 2023

Describe the PR
Host Library:
The unplugging process of the USB device might lead to an infinite loop. It is easy to run into this situation if unplugging occurs during the enumeration process. Also, it happens when unplugging while the host and the USB device are doing something.

The issue is really big. As the stack enters an infinite loop when this is happening.

Additional context
I am testing with the RA4M2 family, with no OS. I know this fix is not meant if you are hosting a hub device. However, if you are planning to host a single device, it increases the robustness of plugging/unplugging while busy issue.
This was tested with MSC devices, I can see the improvement.

@hathach I am not sure if this fix is contagious for other scenarios. Please let me know if I need to take care of something else.

Thank you.

@abakosh
Copy link
Author

abakosh commented Aug 4, 2023

image

@mdevaev
Copy link

mdevaev commented Aug 15, 2023

@hathach @abakosh Sup. I also ran into this problem, but on RP2040. Do I understand correctly that this hack will help me solve this problem on RP2040, if I don't use the hub? Do you see any pitfalls with this?

@abakosh
Copy link
Author

abakosh commented Aug 15, 2023

As @hathach said, it is hacky, not a clean way. However, for me, it works perfectly. The pitful will be if the port is supporting a hub or if the rp2040 usb supports two ports as well that you are using as a host. In a single port full speed host for mass storage, this hack will work like a charm 👌, please let me know if it works for you

@mdevaev
Copy link

mdevaev commented Aug 15, 2023

@abakosh It seems it's working great in my case. I came across this today and came to almost the same solution as you. As far as I understand, the RP2040 has one port, so everything should be fine.

@karlp
Copy link

karlp commented Sep 3, 2024

Potentiall addressed by the behaviour cahnge in #2550

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.

3 participants