Jetson Tx2 USB 2.0 device mode not working

Hello,

We have designed a custom board based on Jetson TX2. In which we want internal EMMC should be get auto mounted on host PC.

As I can see in the /opt/nvidia/l4t-usb-device-mode/nv-l4t-usb-device-mode-start.sh four modes are defined:

  • RNDIS

  • ACM

  • ECM and

  • MSC

But out of 4 functionality none is working. If I disable ACM, ECM and RNDIS in the script then I can see the mass storage in /sys/kernel/config/usb_gadget/l4t/functions/mass_storage.0/lun.0/. I can see msc.ext4.img in the home folder.

I can not see any detection log in the dmesg also.

I am not able to understand why it is not auto mounting and how we can debug this problem.

Looking forward to hear you back.

Thanks and Regards,
Vikas Dwivedi

I can’t answer much for custom boards, but if you monitor “dmesg --follow” as you insert the micro-B USB connection, then you should see a message about the cable insert. The micro-OTG connector can accept either a micro-A connector or a micro-B connector, and it is the micro-B which has the ID pin. When the ID pin is detected the intent is to switch the port from host mode to device mode. To act as a device, and to trigger whatever software runs in device mode, that ID must be detected.

Make sure your ID pin is electrically available. Make sure your device tree includes ID detect for your wiring layout. Make sure the connector you are using is micro-B (often labeled as a “charger” cable or “OTG” cable…both descriptions make me cringe a bit). Some charger cables literally do not have data wires, or have maybe two copper strands. Even if the cable has terrible data capabilities it should still show a dmesg log denoting the ID pin detect (device mode) upon insert.

I can’t help with the rest of it, but the first step will always be to verify the port is correctly detected.

Hi,
After you connect TX2 to a host PC wit type-A to micro-B cable, you should see L4T-README folder popping up. There are several READMEs in the fold and please take a look.

Hello,

Thank you for all your effort and help.

Due to some hardware dependency I was not able to configure USB2.0 in device mode but now it is going in device mode and able to mount on the Host PC.

I made some changes in nv-l4t-usb-device-mode-config.sh file to mount /dev/mmcblkp1 . This partition is getting mounted on the host PC with the read and write permission.

As per my requirement, I want to give access of a data folder only of home directory and want to lock root file system so that no one can make the changes in the root file system.

How we can lock root file system can only allow a specific folder inside home directory. Is it possible to mount only specific folder ? If yes, how we can do that?

Regards,
Vikas

Just a reference for anyone working on mass storage gadgets:
https://www.kernel.org/doc/html/latest//usb/mass-storage.html

There is a reference for gadget in general here:
https://www.kernel.org/doc/html/latest//usb/gadget_configfs.html

Do look closely at this quote from the mass storage document regarding the memory (file or device special file) used as backing store:
BEWARE that if a file is used as a backing storage, it may not be modified by any other process. This is because the host assumes the data does not change without its knowledge. It may be read, but (if the logical unit is writable) due to buffering on the host side, the contents are not well defined.

You could make the home directory read-only to the gadget, and then have read-write access as a normal user. Or you can have the reverse where the home directory is not available for writing by any login, but the gadget would be read-write. You can’t have both.

A gadget device is more or less like mounting the partition. Two separate computers cannot mount and control a partition simultaneously. Simultaneous mount (and the ability for more than one computer to write) is the role of NFS (or if speaking to Windows, SAMBA). There are other “distributed filesystems”, but NFS is the main way to do this among *NIX computers, while SAMBA is the way to go when Windows is to participate.