-
Notifications
You must be signed in to change notification settings - Fork 1.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
RP2040 PIO USB Host does not detect device unplug #2971
Comments
I just re-checked my setup and now I cannot make my workaround work. See LOG=2 result. |
I pushed a change to the usb_midi_host application driver to stop all transfer requests once one transfer fails. For Pico-PIO-USB hosts with hub attached, it does not fix the issue. However, now workaround patch I proposed above works to fix the issue. I verified this on an Adafruit Feather RP2040 with USB A Host board. |
I tried to solve this in pico-pio-usb with d17f8ef, it would hang when certain devices were unplugged, but that probably didn't do enough. I added another timeout here: 5122927 which seemed to make things better but I'm not 100% on if that'll work in all cases. I think if there's nothing to read from ACK, the RX buffer index is never incremented so it can still hang there without a timeout. |
@wiredopposite The fixes you mention probably helped with plug and unplug when the device is connected to the host directly. When the device is connected through a hub, the first transfer to the hub after a failed IN or OUT transfer to a device disconnected from the hub fails. At around line 297, I printed the return value from
I observe the transfer that fails because the device is not connected returns -2. The host poll of the hub IN interrupt returns -1. Does that point to a PIO state machine getting stuck after a failed transfer? |
I observe that if I roll back the Pico-PIO-USB library to version 0.5.3, this problem goes away. I am closing this issue in this library. |
@rppicomidi #2994 improve hub driver with pio-usb, there is still more to push. Let me know if that helps with your issue |
Operating System
Linux
Board
Feather RP2040 with USB A Host
Firmware
https://github.com/rppicomidi/usb_midi_host/tree/main/examples/C-code/usb_midi_host_pio_example
I think the version in GitHub may not have specific support for the Feather board yet, but it will shortly.
What happened ?
I have connected a powered USB 2.0 hub to the USB A port of the Feather board. If I plug a MIDI device to the hub, it enumerates correctly and starts working. If I unplug the hub from the Feather board, the software correctly detects the MIDI device is unplugged. If I plug the hub back in with the MIDI device still connected, it enumerates again and starts working again. However, if I leave the hub plugged in and unplug the device, the software does not detect the MIDI device was unplugged.
If I build firmware that uses the native RP2040 USB hardware for the USB host, I do not see this issue.
How to reproduce ?
Pico MIDI Host Example
message on the serial terminalDebug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
I lost my log files, but logs showed first the bulk transfer failed from the MIDI device, which is expected, but then the interrupt IN transfer failed from the hub, which is not. The file
hub.c
is coded so that if the transfer result is notXFER_RESULT_SUCCESS
, then the host stops polling the hub for status change.Screenshots
@hathach I can work around this issue with the following patch to
hub.c
, but I think that maybe this is not really fixing the bug. If you have advice where to look in the HCD for TinyUSB or in the low-level stuff in the Pico-PIO-USB project, I will try to make a pull request. If you want a pull request with fix below, I can do that too.I have checked existing issues, dicussion and documentation
The text was updated successfully, but these errors were encountered: