How to switch USB OTG to host mode?

Dear Forum,

We would like to know how to enable the USB OTG interface (type C) into host mode for communicating with external MCU via USB to UART converter in normal booting for example, please ? Is it feasible to do that via firmware /software (device-tree, sysfs, …) or necessary to modify the hardware?

Knowing that we are using Jetpack-5.1.x.

Thanks and best regards,

Khang

Hardcoded to host mode is possible but still may need to check your hardware design to see how your USB type C is implemented.

Below document for modifying device tree.

and want to clarify again. Modifying device tree may lead to system crash.

lacking of UART debug console on the board might lead to difficulties.

Hi @WayneWWW ,

Thanks for reminding about the UART DEBUG. We also plan to add it. And for additional information, the current USB-3.0 block is as below :

Just want to clarify. What is your current configuration in the device tree?

I mean, enabling such design on a custom board is much difficulties than hardcoded a host mode…

Hi @WayneWWW ,

How can I check this by software in the running Tegra Linux?

My current SOM is Jetson Orin NX and custom carrier board recognized by the sdkmanager, and I used this later to flash the Jetpack-5.1.5 onto it. Therefore, the BSP firmware is the default one from Nvidia for this SOM.

Best Regards,
Khang.

HI @WayneWWW

Sorry to bother you. I tested myself to dynamically switch btw modes and they worked :

# echo host > /sys/class/usb_role/usb2-0-role-switch/role

In default mode :

# cat /sys/class/usb_role/usb2-0-role-switch/role
none

I have one question here.

What is the exact thing that you want to do here?

Do you want your current type C port untouched and just one to connect a USB device to it and make your Jetson as host mode?

If so, then why are you doing mode change by yourself? I mean, a correct OTG solution won’t need yourself to " echo host > /sys/class/usb_role/usb2-0-role-switch/role" to enable a host mode.

OTG itself is a mode that could be switched between host and device. When you connect a USB device to it, “/sys/class/usb_role/usb2-0-role-switch/role” will be a host mode automatically. It does not need you to “echo host” or “echo device” each time you are hotplugging a USB cable.

Hi @WayneWWW ,
What I expected were :

  • The OTG type C port became the host mode automatically in normal boot and and to be used for connecting a keyboard and mouse (via an external USB hub).
  • The OTG type C port became the device mode automatically in normal boot when I connect a cable to the PC (in order to be a backup Ethernet over USB connection to the board via the 192.168.55.x network)

However, neither of above mode worked automatically. And the default role was none. That why I had to switch the mode manually to verify if the physical port functions.

Then it is back to what I just said in previous comment.

You didn’t successfully enable OTG port so that you have to do those manual operations by yourself.

This topic is wrong. The topic should be “how to enable OTG port on custom board”.

Default dtb from sdkmanager is for NV devkit. It does not know your custom board design. OTG is working fine on NV devkit but that won’t happen on your board.

You have to do below items first

  1. Check with the vendor if that HD3SS3220IRNHT requires specific drivers + device tree setting. I feel it is needed because there are i2c connected to the chip. Our I2C won’t work without extra driver on such chip.

  2. Read the previous document I posted and modify the device tree for tegra USB part. Devkit is using FUSB301 and your case is different. You have to replace that part.

Hi @WayneWWW ,

I checked with HW team and effectively there’s difference btw the custom board vs the orin nano devkit at least in term of the mux IC for the USB3 type C block. I will investigate more on this difference relevant to the reason why the mode detection/switching did not happen automatically. According to an older discussion, the HD3SS3220IRNHT could be configured by hardware (registors) without enabling its driver (available since Jetpack-5.1.1) and configuration in device-tree. I will dive deeper into the document of the HD3SS3220IRNHT and test more then update to you when possible.

Hi,

You may need to read what you just posted carefully.

The post you shared from 2023 was actually a “host mode” only type C port. It does not truly enable OTG…
Their design is USB2-1 + USB3-1. Their port is not involved with flashing port.

For OTG mode, it is not just about how your hardware programming does in HD3SS3220IRNHT.

The Linux kernel framework that our USB host and device controllers are using to communicate with such IC is the “remote-endpoint” one. You could refer to default device tree to understand what I mean here.

Better checking with the vendor how to deal with such case.