I'm having a hard time automating loading a gadget module and bringing up the usb0 device as a eth interface. The interface in question is g_ether for a embedded Linux device and connecting to a PC.

I imagine there is a way to see the event from the plugin and run a script with udev. When I plug my device into a PC, I don't see any events. I tried different variations of udevadm monitor and I'm not sure how to find out what I can use as a udev rule to modprobe a gadget module.

Part of the reason I'm trying to load the otg module is because we are mostly using g_ether. I want to use avahi-autoipd but its getting an IP address before its plugged in. If I use allow-hotplug in the network interface it never automatically brings the interface up when its plugged in. So in theory, I want to plug in the device to a PC, run avahi-autoipd on the new network interface to retrieve an IP, and dhcpd to give one to the host.

Since someone else starting helping me in the stackoverflow (reposting here) I've got some more info.

/sys/bus/usb/devices$ ls
1-0:1.0  2-0:1.0  3-0:1.0  3-1  3-1:1.0  usb1  usb2  usb3
[ 4297.515400] g_ether gadget: high speed config #2: RNDIS
[ 4300.379021] g_ether gadget: high speed config #1: CDC Ethernet (ECM)
sys/bus/usb/devices$ ls
1-0:1.0  2-0:1.0  3-0:1.0  3-1  3-1:1.0  usb1  usb2  usb3

I've tried running

   udevadm monitor --environment
   udevadm monitor --environment --udev 
   udevadm monitor
   udevadm monitor --kernel
   udevadm monitor --kernel --udev

unplugging and plugging the device in doesn't show anything. The manpage says it " Listens to the kernel uevents and events sent out by a udev rule" and I have no rules on my device. So I'm assuming that's probably why nothing prints out ever, even if I try to do some things with other hardware?

I'm running an embedded Linux distribution. I imagine I might not have everything a desktop has?

Its come to my attention I might have an issue with my g_ether module? These outputs never change. cat /sys/class/net/usb0/carrier cat: read error: Invalid argument cat /sys/class/net/usb0/operstate down


1 Answer 1


USB specific variables for a uevent are set in kernel function usb_uevent. You can track if this function is called or not.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .