-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Operating System
Linux
Commit SHA
8f2e3ed, current master
Board
Pi Pico 1 / RP2040
Firmware
Custom firmware for FPGA Companion https://github.com/MiSTle-Dev/FPGA-Companion
Running inside FreeRTOS, using PIO-PICO-USB, also latest master
This is actually extensively used for the MiSTle retro gaming project, where TinyUSB is used on a rp2040 to control keyboard, mouse and joysticks in a FPGA retro gaming setup.
What happened ?
Sometimes (with debugging enabled) or very often (without debugging), unplug events on a CH334 hub are missed and the stack goes nuts as it still tries to communicate with the now missing devices.
How to reproduce ?
Use the FPGA Companion on a MiSTle setup and unplug a device.
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
The HUB xfer callback for the unplug event fails:
[2] Claimed EP 0x81
Queue EP 81 with 64 bytes ...
OK
[:5] on EP 81 with 0 bytes: FAILED
HUB xfer callback
[5] Claimed EP 0x81
Queue EP 81 with 1 bytes ...
OK
Afterward, the stack goes nuts as it didn't get the unplug event and still tries to communicate with the now missing devices.
If I ignore the test for a good result in
Line 364 in 8f2e3ed
if (result == XFER_RESULT_SUCCESS) { |
/* if (result == XFER_RESULT_SUCCESS) */ {
Then, the broken message still contains enough information to actually handle the unplug event correctly. The status change byte is especially correct:
[:5] on EP 81 with 0 bytes: FAILED
HUB xfer callback
Processing failed hub cb, anyways
Hub Status Change = 0x08
HUB Get Port Status: addr = 5 port = 3
[1:5] Class Request: A3 00 00 00 03 00 04 00
[:5] on EP 00 with 8 bytes: OK
[:5] on EP 80 with 4 bytes: OK
[1:5] Control data:
0000: 00 01 01 00 |....|
[:5] on EP 00 with 0 bytes: OK
Everything works fine, now. This is ok for now, but this doesn't sound like a good solution.
How would I debug this further? The hub is soldered on-board, so I cannot simply test a different one.
I'll try to set up a bare-bones system with a different hub. I'll also try to set up a variant that uses the RP2040's native USB vs. the PIO-USB we are currently using (and which we'd like to continue using, as PIO can be used through the pin headers).
Screenshots
No response
I have checked existing issues, discussion and documentation
- I confirm I have checked existing issues, discussion and documentation.