Repository navigation
usbhost: a flash drive in the GIGA's USB-A port is listed and mounts - #403
Merged
Merged
Conversation
A USB flash drive plugged straight into the Arduino GIGA R1's USB-A port was never listed: usbhost_simpletest.py printed "0 USB device(s) found". The drive is still starting up when TinyUSB resets it 150 ms after it appears, so it doesn't answer the first device descriptor request, and TinyUSB gave up on the port after that one attempt. A new patch, patches/lib-tinyusb/0002, resets and enumerates a root port again after a failed attach, up to three times, as later TinyUSB releases do. On the GIGA with a PNY 8 GB drive in the port, the drive now attaches about 520 ms after usb.core.start(), the simpletest lists 154b:009f and usb_drive_mount.py lists its files. test_tuh_enum_retry.c runs TinyUSB's host stack on a PC over a fake controller and a drive that ignores its first 300 ms; CI runs it with the patch, and checks that it fails without.
The usbhost workflow builds test_tuh_enum_retry.c against TinyUSB at the commit the pinned MicroPython uses: with patches/lib-tinyusb/ applied it has to pass, and with only 0001 it has to fail. The simpletest's and usb_drive_mount.py's Tested on lines add the GIGA R1 run with a PNY drive in its USB-A port.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A USB flash drive plugged straight into the Arduino GIGA R1's USB-A port is now listed and mounts. Before,
usbhost_simpletest.pyprinted0 USB device(s) foundwith the drive in the port, however long it waited.The port's power and the host controller were fine: with the host started, the port showed a full-speed device connected and enabled, and the host sent its first SETUP. The drive didn't answer it. It is still starting up when TinyUSB resets it 150 ms after it appears: register-level tries on the board showed it ignoring the device descriptor request 10 ms after that reset and answering 20 ms after it, and answering at once from then on. TinyUSB's root port gets one enumeration, so after that failure it never tried again and the drive stayed connected and unlisted. A new patch,
patches/lib-tinyusb/0002, posts the attach again after a failed enumeration on a root port that still has a device, up to three times, so the port is debounced, reset and enumerated anew; later TinyUSB releases have the same root-port retry. It also closes dev0's control endpoint after a failure before addressing, which every retry would otherwise leak. Devices behind a hub were never affected: the hub's next port status change already retries them.On the GIGA with the Display Shield, this branch's firmware (built with displayif, lvgl, audiodsp, audioif, ulab and usbhost) with a PNY 8 GB FAT drive in the USB-A port: the drive attaches about 520 ms after
usb.core.start()in three of three starts, the simpletest prints1 USB device(s) foundand154b:009f,host_enum.pylists it with its strings, andusb_drive_mount.pymounts it read-only and lists its files. The newtests/test_tuh_enum_retry.cbuilds TinyUSB's host stack (at the commit the pinned MicroPython uses, with our patches) on a PC over a fake controller: a drive that ignores its first 300 ms has to mount, a dead device has to stop after its retries with no endpoint left open, and a ready device has to mount on the first reset. CI runs it, and runs it again without 0002 to check that it fails. With the host running, three power cycles of the port (_usbhost.host_port_cycle(), the nearest thing to a replug the board can do itself) each gave a detach and an attach 515 ms later. Not tried: a drive pulled out and plugged in by hand, and a drive behind a hub on this build.