[ale] udev rules for USB

Michael H. Warfield mhw at WittsEnd.com
Sat Nov 30 10:31:31 EST 2013


On Thu, 2013-11-21 at 17:41 -0500, Chris Fowler wrote:
> I'm writing a udev rule that I want to run only when something is
> plugged into a USB port
> 
> ACTION!="add", GOTO="end01"
> 
> BUS=="usb",RUN+="/lib/libexec/usb-load %b %s{idVendor} %s{idProduct}",
> $attr{idVendor}, $s{idProduct}
> 
> SUBSYSTEM!="net", BUS!="usb", GOTO="end01"
> 
> SYSFS{idProduct}=="9700", SYSFS{idVendor}=="0fe6", 
> KERNEL=="*", RUN+="/sbin/modprobe dm9601"
> 
> LABEL="end01"
> 
Well, I took your rules set and tried it on my Fedora system and was
able to make it work with some minor fixeups that have me questioning
what distro and version you're running on.

Obviously, a couple of lines needed to be joined.  I wasn't sure if you
did a literal copy and paste or not.  Line 7 was broken into two lines
in your original message and it wasn't clear if that was broken
originally or not.

Big gotcha was "/lib/libexec/usb-load" on line 3.  Did you mean
"/usr/libexec/usb-load"?  I don't even have a /lib/libexec directory on
Fedora and I don't see one on Ubuntu.  Once that's fixed, by shell
script for /usr/libexec/usb-load runs appropriately but I didn't do it
in perl.

It didn't care if there was a space before the RUN+= stanza, so that was
a red herring in my earlier message.

I get several warning from udevd warning about deprecated stanzas like
this:

udevd[900]: SYSFS{}= will be removed in a future udev version, please
use ATTR{}= to match the event device, or ATTRS{}= to match a parent
device, in /etc/udev/rules.d/99-test.rules:7

udevd[900]: BUS= will be removed in a future udev version, please use
SUBSYSTEM= to match the event device, or SUBSYSTEMS= to match a parent
device, in /etc/udev/rules.d/99-test.rules:3

You might want to fix those but those also raise the issue of what
distro and version of udevd are you running.


> My goal is to load the necessary modules on this system.  The problem
> is that the perl script 'usb-load' is not executed.   I can easily
> remove the BUS=="usb" part and have it run on all devices and it can
> look at devpath to see USB.  The problem is that this would be cpu
> intensive.   I want it to execute whenever a usb-serial, usb-modem, or
> usb-storage device is attached.   In some cases the kernel does not
> know that a certain vId and pId is attached to a driver and I have to
> load it myself.  You see that example where I am having to load the
> dm9601 driver for a usb-net device.   I see the same for usb-storage.
> Some USB sticks the kernel loads usb-storage for some it does not know
> to. If I capture the vId and pId I can then look it up and load up the
> correct one.
> 
> Chris

Regards,
Mike
-- 
Michael H. Warfield (AI4NB) | (770) 978-7061 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://mail.ale.org/pipermail/ale/attachments/20131130/c16503c2/attachment.sig>


More information about the Ale mailing list