After some debugging and help from ChatGPT I got the USB HUB working on NuttX. It was failing because the USB HUB driver on NuttX was missing the USB HUB Class 9 with Protocol 2 (Mult. TT HS HUB).
After fixing it everything worked as a charm:
nx_start: Entry
uart_register: Registering /dev/console
uart_register: Registering /dev/ttyS0
work_start_highpri: Starting high-priority kernel worker thread(s)
work_start_lowpri: Starting low-priority kernel worker thread(s)
nx_start_application: Starting init thread
up_release_pending: From TCB=0x20201208
usbhost_registerclass: Registering class:0x202000f8 nids:3
usbhost_registerclass: Registering class:0x20200108 nids:1
imxrt_usbhost_vbusdrive: RHPort1: enable=1
usbmonitor_start: Started: 5
ehci_waiter: ehci_waiter: Running
ehci_waiter: connected
usbmonitor_daemon: Running: 5
nx_start: CPU0: Beginning Idle Loop
NuttShell (NSH) NuttX-10.3.0
nsh> usbhost_enumerate: maxpacksetsize: 64
usbhost_devdesc: class:9 subclass:0000 protocol:0002 vid:1060 pid:9495
usbhost_enumerate: sizeof config data: 41
usbhost_findclass: Looking for class:9 subclass:0 protocol:2 vid:0424 pid:2517
usbhost_findclass: Checking class:0x20200108 nids:1
usbhost_idmatch: Compare to class:8 subclass:6 protocol:80 vid:0000 pid:0000
usbhost_idmatch: To DEVICE class:9 subclass:0 protocol:2 vid:0424 pid:2517
usbhost_findclass: Checking class:0x202000f8 nids:3
usbhost_idmatch: Compare to class:9 subclass:0 protocol:0 vid:0000 pid:0000
usbhost_idmatch: To DEVICE class:9 subclass:0 protocol:2 vid:0424 pid:2517
usbhost_idmatch: Compare to class:9 subclass:0 protocol:1 vid:0000 pid:0000
usbhost_idmatch: To DEVICE class:9 subclass:0 protocol:2 vid:0424 pid:2517
usbhost_idmatch: Compare to class:9 subclass:0 protocol:2 vid:0000 pid:0000
usbhost_idmatch: To DEVICE class:9 subclass:0 protocol:2 vid:0424 pid:2517
usbhost_findclass:
Class Found!!! 0x9
usbhost_classbind: usbhost_findclass: 0x202000f8
usbhost_classbind: CLASS_CREATE: 0x20208f70
usbhost_cfgdesc: Interface descriptor
usbhost_cfgdesc: Endpoint descriptor
usbhost_cfgdesc: Interrupt IN EP:usbhost_cfgdesc: addr=1 interval=12 mxpacketsiz1
usbhost_cfgdesc: Endpoint allocated
usbhost_hubdesc: Read hub descriptor
usbhost_hubdesc: Hub Descriptor:
usbhost_hubdesc: bDescLength: 9
usbhost_hubdesc: bDescriptorType: 0x29
usbhost_hubdesc: bNbrPorts: 7
usbhost_hubdesc: wHubCharacteristics: 0x0089
usbhost_hubdesc: lpsm: 1
usbhost_hubdesc: compounddev: FALSE
usbhost_hubdesc: ocmode: 1
usbhost_hubdesc: indicator: TRUE
usbhost_hubdesc: bPwrOn2PwrGood: 50
usbhost_hubdesc: pwrondelay: 100
usbhost_hubdesc: bHubContrCurrent: 1
usbhost_hubdesc: DeviceRemovable: 0
usbhost_hubdesc: PortPwrCtrlMask: 255
usbhost_classbind: Returning: 0
EHCI Initializing EHCI Stack
EHCI HCIVERSION 1.00
EHCI nports=1, HCSPARAMS=0011
EHCI HCCPARAMS=000006
EHCI Interrupt: 000004
EHCI PORTSC1: 0803
EHCI Connect Status Change: 000803
EHCI RHPort1 connected, pscwait: 0
EHCI USB EHCI Initialized
EHCI RHPort1 connected: 1
EHCI Interrupt: 000004
EHCI PORTSC1: 0205
EHCI Hub port 0: Enumerate the device
EHCI CTRLIN/OUT: RHPort1 req: 06
EHCI Async transfer EP0 buflen=18
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8c00
EHCI CTRLIN/OUT: RHPort1 req: 05
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 06
EHCI Async transfer EP0 buflen=9
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8c00
EHCI CTRLIN/OUT: RHPort1 req: 06
EHCI Async transfer EP0 buflen=41
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8c00
EHCI CTRLIN/OUT: RHPort1 req: 09
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI EPALLOC: EP1 TYPE=3
EHCI CTRLIN/OUT: RHPort1 req: 06
EHCI Async transfer EP0 buflen=9
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8c00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI CTRLIN/OUT: RHPort1 req: 03
EHCI Async transfer EP0 buflen=0
EHCI Interrupt: 000001
EHCI USB Interrupt (USBINT) Interrupt: 000001
EHCI IOC EP0 TOKEN=8d00
EHCI Intr Transfer EP1 buflen=1
This is the patch (that I will submit to mainline)
$ git diff drivers/usbhost/usbhost_hub.c
diff --git a/drivers/usbhost/usbhost_hub.c b/drivers/usbhost/usbhost_hub.c
index ee642fbeff..5f0bcf99c5 100644
--- a/drivers/usbhost/usbhost_hub.c
+++ b/drivers/usbhost/usbhost_hub.c
@@ -103,6 +103,10 @@
#define PORT_INDX(x) ((x) - 1)
+/* Array size to avoid mistake adding new item to g_id */
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -184,7 +188,7 @@ static int usbhost_disconnected(FAR struct usbhost_class_s *hubclass);
* used to associate the USB host hub class to a connected USB hub.
*/
-static const struct usbhost_id_s g_id[2] =
+static const struct usbhost_id_s g_id[] =
{
{
USB_CLASS_HUB, /* base */
@@ -196,7 +200,14 @@ static const struct usbhost_id_s g_id[2] =
{
USB_CLASS_HUB, /* base */
0, /* subclass */
- 1, /* proto HS hub */
+ 1, /* proto Single TT HS hub */
+ 0, /* vid */
+ 0 /* pid */
+ },
+ {
+ USB_CLASS_HUB, /* base */
+ 0, /* subclass */
+ 2, /* proto Multiple TT HS hub */
0, /* vid */
0 /* pid */
}
@@ -208,7 +219,7 @@ static struct usbhost_registry_s g_hub =
{
NULL, /* flink */
usbhost_create, /* create */
- 2, /* nids */
+ ARRAY_SIZE(g_id), /* nids */
g_id /* id[] */
};