USB storage not found in U-Boot when using USB Hub - Apalis iMX8

Hi,

We are trying to use a USB storage device to use the USB boot on our custom carrier board.
The USB storage is normally found when it is used with a “direct” USB connection to the carrier board, but when we use USB Hub we cannot see any USB storage found in U-Boot after the “usb start/reset” command.

The USB can be normally used in a Linux userspace (can be seen as a device and can be mounted/used normally), no matter if it’s connected “directly” or through the USB Hub.

Is there any way to use the USB storage device with USB hub in U-Boot?

Hardware used:
Apalis iMX8 (imx8qm without wifi model)
Custom carrier board
Microchip USB7002 USB Hub

Software used:
U-Boot (u-boot-toradex) version: 2020.04-0+git.586f79f64f6a
Linux kernel (linux-toradex) version: 5.4.91+gitAUTOINC+590db576d0
Custom Yocto distribution with layers:
meta-toradex-nxp (version: dunfell-5.x.y - 599cd72b82723ac096bb5c9bea2d82bdc6b38185);
meta-toradex-bsp-common (version: dunfell-5.x.y - 2b830c7a4aaf39dc7ea971c638b5042290c9ee1e)

If I could add any information to this, please tell me.

Kind regards,
Domagoj

The U_Boot does not init USB interface by default. You should issue U_Boot usb start command to activate it.

Hi,

as I said in the first message when I use the “usb start” or “usb reset” command it does show the “USB storage device found” when there is USB device connected “directly” to the carrier board (Apalis iMX8), but the problem is that it does not find the USB device when is connected through USB Hub (Microchip USB7002).

I normally use “usb start” commands and they are working fine, but they do not find the USB storage device when it is connected through USB Hub, even though it is working OK in Linux userspace.

Kind regards,
Domagoj

U_Boot should access USB mass storage even if it’s connected trough hub. I’ve tested USB2 and USB 3 hubs with Ixora board and haven’t found any issue:

Apalis iMX8 # usb start
starting USB...
Bus usb@5b0d0000: usb dr_mode not found
Port not available.
Bus usbh3: XHCI-imx8 init hccr 0x000000005b130000 and hcor 0x000000005b130080 hc_length 128
Register 2000820 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus usbh3 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Apalis iMX8 # usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 100mA)
    |   USB 2.0 Hub
    |
    +-3  Mass Storage (480 Mb/s, 300mA)
         Kingston DataTraveler 3.0 408D5CE57214B050C9391F0A

Apalis iMX8 # usb reset
resetting USB...
Bus usb@5b0d0000: usb dr_mode not found
Port not available.
Bus usbh3: XHCI-imx8 init hccr 0x000000005b130000 and hcor 0x000000005b130080 hc_length 128
Register 2000820 NbrPorts 2
Starting the controller
USB XHCI 1.00
3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Apalis iMX8 # usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller
  |
  +-2  Hub (5 Gb/s, 0mA)
    |  GenesysLogic USB3.0 Hub
    |
    +-3  Mass Storage (5 Gb/s, 126mA)
         Kingston DataTraveler 3.0 408D5CE57214B050C9391F0A

Is your USB7002 integrated on carrier board? Could you share results of USB start command?

Hello Alex,

today I’ve found some old procedures we had when we first started to use “usbboot” on our boards.
In the notes, I have found that sometimes before using USB, GPIO #132 needs to be “set” (brought up) in order to have a properly working USB.
I am not sure what it does, but the USB is working afterward.
I can only see in the schematic of our carrier board that Apalis pin #132 is connected to the “UART RX” pin on the internal eMMC memory module (on the carrier board) which has nothing to do with the USB, I think that the nomenclature for U-Boot GPIO pins is different than the actual pin numbers.

In the Apalis iMX8 datasheet, I found these pins and they control the enable pins of the USB.

Now I can normally use the USB-Hub and USB storage devices connected through it.
I am sending you a full output of the commands in U-Boot:

U-Boot 2020.04-0+git.586f79f64f6a (Jan 27 2021 - 16:05:21 +0000)

CPU:   NXP i.MX8QM RevB A53 at 1200 MHz

DRAM:  4 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex Apalis iMX8 QuadMax 4GB IT V1.1C, Serial# 06852565

 BuildInfo: 
  - SCFW 0d54291f, SECO-FW d63fdb21, IMX-MKIMAGE 8947fea3, ATF 7f1187b
  - U-Boot 2020.04-0+git.586f79f64f6a 

flash target is MMC:0
Net:   eth0: ethernet@5b040000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0 
Apalis iMX8 # 
Apalis iMX8 # usb reset
resetting USB...
Bus usb@5b0d0000: usb dr_mode not found
USB EHCI 1.00
Bus usbh3: XHCI-imx8 init hccr 0x000000005b130000 and hcor 0x000000005b130080 hc_length 128
Register 2000820 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus usb@5b0d0000 for devices... 1 USB Device(s) found
scanning bus usbh3 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Apalis iMX8 # usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller 
   
  1  Hub (5 Gb/s, 0mA)
     U-Boot XHCI Host Controller 
   
Apalis iMX8 # gpio set 132
gpio: pin 132 (gpio 132) value is 1
Apalis iMX8 # usb reset
resetting USB...
Bus usb@5b0d0000: usb dr_mode not found
USB EHCI 1.00
Bus usbh3: XHCI-imx8 init hccr 0x000000005b130000 and hcor 0x000000005b130080 hc_length 128
Register 2000820 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus usb@5b0d0000 for devices... 1 USB Device(s) found
scanning bus usbh3 for devices... 5 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Apalis iMX8 # usb tree
USB device tree:
  1  Hub (480 Mb/s, 0mA)
     u-boot EHCI Host Controller 
   
  1  Hub (5 Gb/s, 0mA)
  |  U-Boot XHCI Host Controller 
  |
  +-2  Hub (5 Gb/s, 0mA)
  | |  RImac Automobili d.o.o. USB_42x Series 210720PP09132A
  | |
  | +-4  Mass Storage (5 Gb/s, 74mA)
  |      Kingston DataTraveler 70 0C9D9210E304F4C0193202A2
  |    
  +-3  Hub (480 Mb/s, 0mA)
    |  RImac Automobili d.o.o. USB_42x Series 210720PP09132A
    |
    +-5  Vendor specific (480 Mb/s, 0mA)
         Rimac Automobili d.o.o. USB_42x Series 210720PP09132A
       
Apalis iMX8 # 

In the output above can be seen that USB storage and USB Hub are visible in U-Boot only after GPIO #132 is set.
The USB7002 is located on our external board (which is connected to the carrier board with an automotive USB cable-more robust connector).

If you can please explain how these GPIO numbers translate to U-Boot so we can maybe avoid this in the future.
But for now, we can call this issue solved.

Kind regards,
Domagoj

Translation is simple

port = gpio / 32 ;
bit = gpio & 0x1f;

You can see it here.

So gpio132 is LSIO.GPIO4.IO04 and it’s routed to X1 pin 84. Is this pin connected to your USB hub somehow?

Hi Alex,

Yes, pin 84 is connected to enable pin on the power supply of the USB connector on the carrier board.
I really don’t know how this was working OK without the USB Hub, but surely now it is working OK.

Thank you a lot for the explanation on how to calculate specific GPIO pins, it is really useful.

You are welcome. Please note that this translation is only applicable for U_Boot. Linux uses different translation algorithm

However it’s strange that you need to “manually” set pin 84 (USBH_EN). It should be set high automatically when you do #usb start. Otherwise USB interfaces on Ixora board will not be available. Please check the Ixora board schematic.

Could you share part of your carrier board schematic related to USB?

.