drivers/usbhost: Report each device as it is enumerated. - #19751
Merged
xiaoxiang781216 merged 1 commit intoAug 8, 2026
Conversation
Fishwaldo
requested review from
jerpelea,
johannes-nivus and
yamt
as code owners
August 8, 2026 09:55
Fishwaldo
force-pushed
the
upstream-usbhost-announce
branch
from
August 8, 2026 10:23
4231889 to
b23ce22
Compare
A host that enumerates a device says nothing about it unless the whole of CONFIG_DEBUG_USB_INFO is on, and then it says a great deal else besides. The quietest case is the one that matters most: a device no class driver claims produces no output at all, so a user with an unsupported device sees exactly what a user with no device sees. Add CONFIG_USBHOST_ANNOUNCE, reporting each device once, in the shape a reader is likely to recognise from other systems: where it is, what it is, its vendor, product and release, and the maker, product and serial number it reports in its own string descriptors. Those cost a control transfer each, so they are read only where a report was asked for, and only once the device is addressed. The report is made after binding rather than from within it, because a composite device never reaches the class lookup: usbhost_composite() is tried first and binds it. Whether a driver claimed the device is tracked rather than read from the returned status, which the per interface loop sets to OK whatever happened. The port is given as the path from the root hub, and the path names the bus, because a device on the first port of a hub and one on the first port of a controller are otherwise reported identically. struct usbhost_roothubport_s gains that bus number for the purpose; a driver that does not set it reports zero, which is the only bus it has. Class codes are translated where a name is more use than a number, which includes the HID boot protocols, so a keyboard is reported as a keyboard. Default n, so no existing configuration changes. Assisted-by: Claude:claude-opus-5 Signed-off-by: Justin Hammond <justin@dynam.ac>
Fishwaldo
force-pushed
the
upstream-usbhost-announce
branch
from
August 8, 2026 12:07
b23ce22 to
7c2f63d
Compare
Contributor
Author
|
Thanks for the review @xiaoxiang781216 updated based on your feedback |
acassis
approved these changes
Aug 8, 2026
xiaoxiang781216
approved these changes
Aug 8, 2026
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.
Summary
This is mainly a quality of life improvement for anyone debugging USB on NuttX.
When a device is plugged in, the host says nothing about it. If a class driver claims it, a node appears in
/devand you can infer what happened. If nothing claims it, an unsupported device or a supported one whose driver is not in the build, there is no output at all, and no way to tell the difference between "unsupported device" and "nothing plugged in". The information exists; it is simply thrown away unless you enableCONFIG_DEBUG_USB_INFO, which then buries it in everything else the stack has to say.CONFIG_USBHOST_ANNOUNCEreports each device once as it is enumerated, in a shape people will recognise from other systems: where it is, what it is, its vendor, product and release, and the maker, product and serial number the device reports in its own string descriptors.Three details are deliberate. The port is given as the path from the root hub and named by bus, because a device on a hub's first port and one on a controller's first port are otherwise reported identically. The report is made after binding rather than from within it, because a composite device never reaches the ordinary class lookup,
usbhost_composite()binds it first, and reporting from there leaves precisely the multi-function devices unmentioned. And whether a driver claimed the device is tracked explicitly rather than read from the returned status, which the per-interface loop sets toOKregardless.Impact
n, so no existing configuration is affected.usbhost_enumerate(), the common path all 27 in-tree HCDs use.struct usbhost_roothubport_sgains abusnumber so a port can be named on a system with more than one controller. A driver that does not set it reports zero, which is the only bus it has.Testing
Host: macOS 15.5 (Apple Silicon). qemu: 10.1.5 with KVM on Fedora 43 x86_64.
Four devices behind a hub on
qemu-xhci: mass storage, a keyboard, and a USB audio device that NuttX has no driver for. Same tree and topology in both runs, differing only inCONFIG_USBHOST_ANNOUNCE.Without the option, the entire bus, in full:
Two nodes appeared. Nothing says the hub exists, and nothing says the audio device was ever attached.
With the option:
The unclaimed audio device is the point: it produces no
/devnode either way, so without this there is nothing at all to tell you it is present, what it is, or why nothing happened.These runs were made with #19745 applied underneath, because
qemu-intel64:jumbois the only in-tree configuration with a USB host controller and on current master that controller does not initialise. The change itself is in the common enumeration path and is independent of any host controller.