How to make an OTG port switch instantly between USB and OTG

I customized a motherboard.

I need to make the OTG port on the Jetson Xavier NX, which is used for flashing the system, switch to a standard USB port for connecting USB devices at any time.

For example: when I plug a mouse into this port, the system detects the USB device, then the system switches the OTG port to a USB port for communication with the mouse.

I have managed to make the system detect whether a USB device is connected.

Normally USB has a type-A or type-B connector. If it is type-A on the computer, then it is a host port and devices plug in to that port with a type-B connector. If it is a type-B on the computer, then it is a device port and exports some device (such as a mouse) when it plugs in to a type-A socket (a host with a host port).

USB is never bi-directional, and handles only one type at a time. The type-C connector has extra wires, and there is a bit of “Jedi trickery” involved in the symmetry of the wiring which allows device or host to use the same plug and socket (still, it is really entirely a single host-to-device wiring).

In the case of older Jetsons which have the micro-OTG port, it is a special port. The micro-OTG port accepts either a type-A micro USB plug or a type-B micro USB plug. There is a detection pin, and this is what tells the Jetson to go into host or device mode. When the Jetson is in host mode and looking for devices (such as a mouse), the action is fairly standard. When a Jetson or any other computer with a micro-B capability plus into another system’s type-A it is dependent upon software as to what kind of device is exported (this is not standard).

FYI, the micro-OTG is often called a “charger” port and cable. This isn’t quite correct, a charger cable is a type-B only, and so it is seen as a device. Something like a smart phone usually turns this into a mass storage device, but that isn’t what such a cable is…the device type itself is programmed in to the particular device.

When programming a port to act as a specific device, then a plug-in event should trigger a certain handshake for mode, and then transfer information as to what the device is. That information is the plug-n-play information which tells the host what is being plugged in, and gives it an idea about driver and other information. In some cases there are some “standard” drivers, and if the device uses a standard driver, then you might use a template for the plug-n-play information which has to be passed on. The Linux kernel has a Gadget framework to assist in creating the information for “standard” devices.

Please clarify at what scenario that you want to use OTG.

@linuxdev has explained the USB background knowledge about it. Whether a USB port supports OTG also involve hardware design. I don’t know if you are trying to ask some knowledge about hardware or you want to know how to configure software like device tree.

Hi !

What I need is knowledge about software.

Thank you !

Are you using Jetpack4 or Jetpack5?

R32.6.2

please refer to
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3275/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/adaptation_and_bringup_xavier_nx.html#wwpID0E06I0HA

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.