forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Milestone
Description
I want to make the USB host implementation more useable for game and synth projects. I'm posting this issue in the hope of getting feedback and core dev buy-in for my list of stuff I'm hoping to fix:
- Unreliable Unplug Event Detection: There's currently no good way to detect an unplugged USB device (some exceptions resulting from an unplug look the same as other types of timeouts). Desktop PyUSB handles this by setting
usb.core.USBError.errno
andusb.core.USBTimeoutError.errno
. (see USB Host: Unreliable Unplug Event Detection #10552) - Corrupted Descriptor Parsing: I started using my own USB device descriptor parser because I would intermittently get nulls or random garbage if I used
usb.core.Device
to do descriptor parsing. I suspect possible memory corruption bugs in the.idVendor
,.idProduct
,.serial_number
,.product
, and.manufacturer
properties ofusb.core.Device
. (see USB Host: Corrupted Descriptor Parsing #10553) - Dropped/Stuck MIDI Notes: When reading MIDI messages from USB MIDI controllers, sometimes note on or note off messages mysteriously go missing. This also happens for other message types, but note on/off is the most problematic. (see USB Host: Dropped/Stuck MIDI Notes #10554)
- Polling Uses Lots of CPU: Anecdotally, it seems like polling for USB host device input events uses a lot of CPU time (not great when also using displayio, picodvi, synthio, etc). For example, when foamyguy ported my Pumpkin Toss game to use I2C gamepad input instead of USB gamepad input, the animation loop ended up running way faster. Maybe this can be improved by using asyncio or something? (see USB Host: Polling Uses Lots of CPU #10555)
- USB Host: Fast polling + write to CIRCUITPY crashes board #10562
- USB Host: Unplugging device can break usb.core.find() #10563
I plan to start looking at some of this stuff and hopefully submit some PRs if I can fix any of it.
Does anybody (Scott, Dan, and foamyguy in particular) have any feedback on this? Is there something else about USB host that you think needs attention? Is there a particular board I should pay attention to for making sure my proposed changes don't increase code size too much (perhaps RP2040 USB Host Feather?). Any other advice on things to pay attention to so the results are mergeable?
[edits: I've added additional issues to the original list of 4]
todbot and relic-se