fix(usbh): robustness against unplugging usb device when it is busy
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.
@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?
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
@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.