[ale] udev rules for USB

Michael H. Warfield mhw at WittsEnd.com
Thu Nov 28 10:58:32 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"

I meant to respond to this last week and then forgot until Erik
responded.  I've done a number of udev rules for USB devices and run
into a number of problems depending on the udevd version (and whether
you are running systemd and it has supplanted udevd).  I don't see
anything OBVIOUS wrong with your BUS=="usb" line but it would be useful
to know if udevd decided it didn't like it for some reason and was
ignoring it (check /var/log/messages).  Might also be useful to post the
distro and version you are running since some rules are udevd version
dependent (although I don't readily see any of the known gotcha's
here)...  Not so sure about your lack of whitespace after that first
comma on that line.  I always make sure I have whitespace after the
comma separating all the stanzas.
> 
> 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.

Did you actually try this and confirm it?  I have some scripts that are
wildcards and they don't really impose that bad of a load (but they're
not perl scripts).

> 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/20131128/70720ffb/attachment-0001.sig>


More information about the Ale mailing list