USB2 host mode (via USB OTG cable)

I can’t get any device to be detected through an USB OTG cable to the micro-USB AB connector. Connecting such cable shows:

[ 6971.009828] as3722-adc-extcon as3722-adc-extcon.2: USB-Host is connected
[ 6971.018586] otg state changed: SUSPEND --> HOST
[ 6971.033956] tegra USB phy - inst[0] platform info:
[ 6971.034107] port_otg: yes
[ 6971.043940] has_hostpc: yes
[ 6971.044087] phy_interface: USB_PHY_INTF_UTMI
[ 6971.045531] op_mode: TEGRA_USB_OPMODE_HOST
[ 6971.045655] vbus_gpio: -1
[ 6971.045749] hot_plug: disabled
[ 6971.045841] remote_wakeup: enabled
[ 6972.062519] tegra-ehci tegra-ehci.0: Tegra EHCI Host Controller
[ 6972.063001] tegra-ehci tegra-ehci.0: new USB bus registered, assigned bus number 3
[ 6972.072905] tegra-ehci tegra-ehci.0: irq 52, io mem 0x7d000000
[ 6972.078868] tegra-ehci tegra-ehci.0: USB 2.0 started, EHCI 1.10
[ 6972.084554] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002
[ 6972.084752] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 6972.084903] usb usb3: Product: Tegra EHCI Host Controller
[ 6972.085042] usb usb3: Manufacturer: Linux 3.10.24-g6a2d13a ehci_hcd
[ 6972.085174] usb usb3: SerialNumber: tegra-ehci.0
[ 6972.132996] hub 3-0:1.0: USB hub found
[ 6972.141605] hub 3-0:1.0: 1 port detected

So it seems to work (a new hub appears).
However, devices connected afterwards to the female end don’t get detected. Once, after plugging a flash drive, and waiting a few minutes, I got it connected, but then it disconnected.

I’ve tried to have everything connected before booting up, but the same exact thing happens (hub appears, device doesn’t).

I’ve tried playing with the power management through sysfs, but nothing helped.
So how can I make this work? Does this work for anyone? Do I need a custom kernel for this to work?

It sounds like you have a bad OTG cable. You should check the pins and/or try a new cable. Unlike regular USB or mini USB, the micro connectors can have problems with pins moving, dust, etc. They are more fragile.
You can check the ID to ground short on the cable using a multi-meter with fine tips, or even better on the Jetson side of the connector (while powered off).

I have had no issue with OTG using either the standard Nvidia L4T 19.3 or the Grinch Kernel.
I can hot plug mouse, keyboard, USB hubs, or flash drives all day into the OTG and it works.

Thanks. I’ll get a new cable and test. It’s pretty hard to test the plug, I guess I’ll get a new socket for testing.

Issue solved. I got a new cable and it works.

For those who get into similar issue in future, it helped for me to reboot the board while having OTG cable inserted (under L4T 21.3). Without reboot I could not make it working.

Both host and device functionality works, but the otg detection does not. I manually control the mode with

/sys/devices/platform/tegra-otg/enable_host
/sys/devices/platform/tegra-otg/enable_device

E.g. for device mode I do:

echo 0 > /sys/devices/platform/tegra-otg/enable_host
echo 1 > /sys/devices/platform/tegra-otg/enable_device

I wanted to test the usb gadget for networking, so in addition I had to do:

echo connect > /sys/devices/platform/tegra-udc.0/udc/tegra-udc.0/soft_connect

Hi I tried the above procedure with sudo
but I still get “permission denied” message

any advice?

The permission denied is resolved now.

Now I need to send the data from the Jetson board a windows PC using the usb-otg?
Any idea how to go about this?
has any one tired this before?

Default USB port mode on Jetson for both connectors is “host mode”. Host mode will listen to “device mode” devices as they connect, and understand what the device claims to be, but a separate driver has to be called to actually use such devices, e.g., keyboards and mice communicate through USB in order to reach the human interface device drivers. The reverse of this is that the micro USB connector can be changed to “device mode” and become a device to communicate to another non-Jetson host. The non-Jetson host needs a driver to use whatever kind of device Jetson says it is, e.g., device-mode Jetson could claim to be a mouse if it wants to.

Jetson is in device mode when booted to recovery mode and has a driver (3pserver) to tell the remote system it is a flashable device from nVidia (nvflash acting as a kind of driver at the other end which understands 3pserver). Running under L4T, no driver exists for device mode despite the port being set up as a device (“the lights are on, but nobody is home”). Thus the computer device-mode Jetson connects to will never know what kind of device Jetson is. What you need on Jetson is a kernel driver which ties to and loads when device-mode is enabled on Jetson (other than recovery mode).

What kind of device do you want Jetson to be? E.G., mass storage…in which case this is the driver type needed.

Thank you @linuxdev :)

I have facing strange issue with Jetson Board with R21.4. For me USB OTG is working good in host mode. I connected Thumb drive and tested the same. But When I tried to test the Device mode nothing happens (It does not work for me).
Before trying to test the device mode I followed the following steps,

echo 0 > /sys/devices/platform/tegra-otg/enable_host
echo 1 > /sys/devices/platform/tegra-otg/enable_device
//I switched to device mode from Host mode

//Then I tried mass storage
modprobe g_mass_storage file=/dev/mmcblk0p1

Also In another boot I tried ether also

modprobe g_ether

In the PC side nothing happens. I tried with different cables and different PCs. Am I missing something?

This thread might help: https://devtalk.nvidia.com/default/topic/764135/jetson-tk1/jetson-tk1-usb-otg-on-l4t-kernel/1

Cross-posted/asked-and-answered.