On Fri, May 11, 2012 at 10:02 PM, Michael J. Hammel <[email protected]> wrote: > I've googled on this but didn't find much, though there was a long > discussion in the BusyBox archives on the extension of mdev event > variables (and other things) that helped. > > I'm looking at using mdev to recognize a USB wifi adapter at boot time. > I've finally figured out that a line like the following will at least > get my handler script called: > > usb.* - - @/usr/bin/spew.sh > > (spew.sh is just a script echoing the event variables passed to it) > > Using a device such as "net.*" doesn't seem to work for USB connected > wifi adapters. I believe using event variables should also work but the > output from spew.sh showed that none of them were getting set except > MDEV, SUBSYSTEM and PWD. I couldn't find a regex for SUBSYTEM that > identified just the wifi adapter.
I had to debug mdev-based device creation and also noticed that it's hard to debug. So I committed some changes which make it emit some diagnostics to /dev/mdev.log (only if this file exists). By looking at environment passed to mdev, I also saw that now kernel sometimes passes $DEVNAME with contents which are more suitable than $DEVPATH. Example: ACTION=add BUSNUM=001 DEVICE=/proc/bus/usb/001/014 DEVNAME=bus/usb/001/014 DEVNUM=014 DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5 DEVTYPE=usb_device MAJOR=189 MINOR=13 PRODUCT=18d1/4e14/227 SEQNUM=1282 SUBSYSTEM=usb TYPE=224/0/0 Clearly, we are _much_ better using $DEVNAME="bus/usb/001/014" as our future /dev node name than basename($DEVPATH)="1-5". So I also added a bit of heuristic "use $DEVNAME if present". > Am I missing something? Is there a better way to auto-load modules for > USB connected devices using mdev? Or am I headed in the right direction > here? Let's start by diagnosing your problem. What sequence of hotplug events do you see? Example: this is what happens when I activate USB tethering on an Android phone (this created USB network device). After many "remove" events, "add" events start to pour in: ACTION=add BUSNUM=001 DEVICE=/proc/bus/usb/001/014 DEVNAME=bus/usb/001/014 DEVNUM=014 DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5 DEVTYPE=usb_device MAJOR=189 MINOR=13 PRODUCT=18d1/4e14/227 SEQNUM=1282 SUBSYSTEM=usb TYPE=224/0/0 mdev: pid: 30940 seq: 1282 action: add mdev: make_device: bus/usb/001/014, /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5, op:0 mdev: mknod: bus/usb/001/014 (189,13) 20660 ACTION=add DEVICE=/proc/bus/usb/001/014 DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0 DEVTYPE=usb_interface INTERFACE=224/1/3 MODALIAS=usb:v18D1p4E14d0227dcE0dsc00dp00icE0isc01ip03 PRODUCT=18d1/4e14/227 SEQNUM=1283 SUBSYSTEM=usb TYPE=224/0/0 mdev: pid: 30943 seq: 1283 action: add mdev: make_device: (null), /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0, op:0 mdev: running: modprobe "$MODALIAS" modprobe: module usb:v18D1p4E14d0227dcE0dsc00dp00icE0isc01ip03 not found in modules.dep ACTION=add DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/net/usb0 IFINDEX=4 INTERFACE=usb0 SEQNUM=1284 SUBSYSTEM=net mdev: pid: 30948 seq: 1284 action: add mdev: make_device: (null), /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/net/usb0, op:0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is a network interface. If your USB wifi thing looks similar, then you can detect it by matching $SUBSYSTEM, $IFINDEX or $INTERFACE. ACTION=add DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/net/usb0/queues/rx-0 SEQNUM=1285 SUBSYSTEM=queues mdev: pid: 30949 seq: 1285 action: add mdev: make_device: (null), /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/net/usb0/queues/rx-0, op:0 ACTION=add DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/net/usb0/queues/tx-0 SEQNUM=1286 SUBSYSTEM=queues mdev: pid: 30950 seq: 1286 action: add mdev: make_device: (null), /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.0/net/usb0/queues/tx-0, op:0 ACTION=add DEVICE=/proc/bus/usb/001/014 DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.1 DEVTYPE=usb_interface DRIVER=rndis_host INTERFACE=10/0/0 MODALIAS=usb:v18D1p4E14d0227dcE0dsc00dp00ic0Aisc00ip00 PRODUCT=18d1/4e14/227 SEQNUM=1287 SUBSYSTEM=usb TYPE=224/0/0 mdev: pid: 30957 seq: 1287 action: add mdev: make_device: (null), /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.1, op:0 mdev: running: modprobe "$MODALIAS" modprobe: module usb:v18D1p4E14d0227dcE0dsc00dp00ic0Aisc00ip00 not found in modules.dep ACTION=add DEVICE=/proc/bus/usb/001/014 DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.2 DEVTYPE=usb_interface INTERFACE=255/66/1 MODALIAS=usb:v18D1p4E14d0227dcE0dsc00dp00icFFisc42ip01 PRODUCT=18d1/4e14/227 SEQNUM=1288 SUBSYSTEM=usb TYPE=224/0/0 mdev: pid: 30958 seq: 1288 action: add mdev: make_device: (null), /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5/1-5:1.2, op:0 mdev: running: modprobe "$MODALIAS" modprobe: module usb:v18D1p4E14d0227dcE0dsc00dp00icFFisc42ip01 not found in modules.dep In general I'd say our mdev.conf syntax looks like a bottleneck now: kernel exports a lot more info than we can match... need to think more about it. -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
