Help with usb_gadget and existing l4t config

I am trying to use “usb_gadget” at the kernel layer to force one of my usb ports to be recognized as Ethernet (rndis) when an android device is plugged in. The goal here is to avoid using a usbc OTG Ethernet adapter, and emulate it on the software side on the Jetson host.

My research has led me to a kernel tool called “usb_gadget”, but as with most things L4T it seems to be a non-standard implementation already setup on the jetson by default.

/sys/kernel/config/usb_gadget/ already has a folder inside called “l4t”… and inside that directory i already see some preconfigured “usb_gadget rules” under …/l4t/functions:

  • acm.GS0
  • mass_storage.0
  • ncm.usb0
  • rndis.usb0

How do i go about modifying the existing rules, or creating new ones so i can accomplish my goal of a “virtual ethernet usb adapter”?

Many of the guides i have found reference enabling “modprobe g_ether” but that does not seem to be installed on the jetson kernel, yet it somehow is able to do rndis usb Ethernet because i believe that is what is used when you connect the Jetson to a Host Ubuntu machine to flash it…

Have made some progress on this issue…

I modified the existing usb_gadgets setup by the jetson to disable the mass storage USB so only the USB Ethernet gadgets are exposed on the OTG port. This stops the phone from immediately presenting as mass storage device.

I even cloned the VID and PID of a known working usb-eth adapter, but it would still not enable the “Ethernet Settings” in android.

I stumbled across this post which indicates why android refuses to treat the usb_gadget as an ethernet device: Why Android can't use CDC Ethernet

However, i was able to make the phone acknowledge the OTG port as an ethernet adapter by changing the MAC address to have a “universal address” with clear U/L bit as indicated here: linux - USB Ethernet on Android devices - Stack Overflow

While this does not automatically trigger the “Ethernet Settings” to appear on its own (likely due to the gadget presenting as usbX instead of ethX), i can manually click the “Ethernet Settings” in android but am not able to establish a connection with Static or DHCP.

Is it possible to have the usb_gadget name the connection ethX instead of usbX to work-around this poorly written regex in the android os?

I can’t answer, but I want to suggest the OTG USB socket wired ethernet is already set up correctly. It uses address for the host PC, and on the Jetson itself. When a host PC plugs this in it sees a virtual wired ethernet device. Any time the host does not use this, it is in the host settings, and not part of the Jetson and not part of the gadget API.

Apparently your Android device is set up with security to not blindly allow random network devices. About the only other possibility is if the cable you are using is low quality, and most “charger” cables fail with any sustained data (2 out of 3 charger cables fail; the cable supplied by NVIDIA is high quality and works).

I suspect that the issue is part of the Android and not part of the Jetson, but edits you’ve made along the way might add confusion. If the Android allows the device, then DHCP will have run and set up. It seems the Android did not make a DHCP request, and so there is no setup (there is no DHCP response if there is no request).

Some more facts i have discovered:

  • Emulating the VID and PID of the known working usb-ethernet OTG dongle makes the usb c cable enable the Ethernet settings in android, but it does not automatically pull up the settings dialog or establish a connection. (if i change it back to stock value, ethernet remains greyed out, if i emulate the dongle VID/PID values Ethernet lights up and i can get into it)

  • When i connect the android to the jetson, i see a new interface “l4tbr0” under ifconfig, is this the name that is being exposed to the android device?

If so, how do i modify the setup so it presents itself as “eth0” which android is expecting to see from the device so it auto-starts the Ethernet config settings? (this is a code flaw in android os with a regex looking for ethX)

I don’t have an Orin Nano. Someone else would have to answer if that is the correct USB connector, and I’m not sure how to describe that on Orin Nano.

Yes, the l4tbr0 is what would have the virtual device address at the Jetson end, with address This is a “managed” interface, and it has other devices associated with it (and the devices change depending on state). That tells you the virtual device is there and ready at the Jetson end. It doesn’t change with whatever is at the remote end.

The remote end (the Android) would get address if successful. The Android could ping the remote via ping, or the Android could ping itself with ping The reverse is true at the Jetson end.

I think there is a misconception here about eth0. This is not something the Android would have any knowledge of if we are speaking of what gets seen at the Jetson side ifconfig. eth0 is private to the Jetson from the Jetson, and is associated with wired ethernet. What you get at the Android end depends on how it is set up. It might be that the Android creates eth0 at its end, which would have address if and only if that device is set up as a DHCP from the Jetson.

The route on the Android determines what network interface is used. Just because the virtual device on the Jetson shows as l4tbr0 don’t let it fool you into thinking this is any different than a device named eth0. Each end will have a network device, and the route goes through that network device, but the name will differ at the Jetson and Android ends.

No device, e.g., eth0 or l4tbr0, exists without a driver at that end. The naming convention is chosen by the operating system (and perhaps via udev rules for anything Linux related, and Android has a Linux kernel).

None of that setup needs to be edited on a default Jetson. It should “just work”. The rules of the Android could interfere though. Security could also get in the way.

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