LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
Search this Thread
Old 11-12-2010, 03:47 AM   #1
wilku
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian Lenny
Posts: 24

Rep: Reputation: 0
Load module on usb dongle insert...


Hi,

I have a problem with a wireless mouse on my laptop running Ubuntu 10.10. If thw receiver is plugged during boot, it works out of the box. But if I plug it in afterwards, I have to manually do
Code:
sudo modprobe usbhid
for it to start workin.

My question is how to automatically load a module when a usb device with a given id is inserted?

Cheers
Tomek
 
Old 11-12-2010, 05:17 AM   #2
wilku
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian Lenny
Posts: 24

Original Poster
Rep: Reputation: 0
I've learned that the correct word is "hotplug"

I have added new file usbhid.conf to /etc/modprobe.d/ with the following content
Code:
#Labtec usb wireless mouse
#alias usb:v1020p0206d*dc*dsc*dp*ic*isc*ip* usbhid
alias usb:v1020p0206d0104dc00dsc00dp00ic03isc01ip02 usbhid
Still no candy. Neither version of alias works. I got the modalias string somewhere from /sys. This is the correct modalias, as the vendor and product id match with lsusb output:
Code:
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 1020:0206 Labtec 
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0846:4260 NetGear, Inc. WG111v3 54 Mbps Wireless [realtek RTL8187B]
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Any ideas?
 
Old 11-12-2010, 05:26 AM   #3
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543
Quote:
Originally Posted by wilku View Post
.

My question is how to automatically load a module when a usb device with a given id is inserted?

Cheers
Tomek
I suggest that "UDEV Rules" would be a good way to accomplish what you're doing. You *may* be able to do (some or all of) it by the way you're doing, but I believe that using UDEV Rules would be more appropriate.

The location of your rules directory may be different depending on your distro, but /etc/udev/rules.d or /lib/udev/rules.d are two common locations.

There are loads of LQ threads dealing with udev rules, and also some pretty good tutotials on the 'net about this topic as well. See Google.

In a udev rule, you can use that 'modalias' value, provided it is unique from all modaliases of your other devices, as part of the matching criteria, and tell udev to insert the usbhid driver when it finds this device, as well as any other things you wish to perform when the device is connected (run a script, issue some commands, etc..).

Best of luck, whichever way you go.

Last edited by GrapefruiTgirl; 11-12-2010 at 05:31 AM.
 
Old 11-12-2010, 05:42 AM   #4
wilku
LQ Newbie
 
Registered: Mar 2005
Distribution: Debian Lenny
Posts: 24

Original Poster
Rep: Reputation: 0
Thank you very much!

I have added this file to /etc/udev/rules.d:
Code:
#Labtec wireless mouse
ACTION=="add", SUBSYSTEM=="usb", MODALIAS=="v1020p0206*", RUN+="/sbin/modprobe usbhid"
It started working. I wonder why it didn't the other way though...
Well, nevermind, it works this way.
Thank you once more.
 
Old 11-12-2010, 05:45 AM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543
I don't know all the ins and outs of this stuff and how everything ties together, but I figure that both modprobe.d/* and the udev rules, play a role, depending precisely when the device is detected; i.e.: is it found during boot, and/or is it found when it is inserted later.

For example, the UDEV rule probably plays a role first, and then, modprobe.d/* are consulted to look for any options or whatever, that are associated with the module being inserted by udev.

If someone has anything to add on this subject, I would be interested in hearing more.

Meanwhile, it's good to hear that you've got some success here!

Cheers.

Last edited by GrapefruiTgirl; 11-12-2010 at 05:47 AM. Reason: Added more.
 
  


Reply

Tags
dongle, insert, load, module, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot able to insert the driver module rajagopalviswanath Linux - Newbie 2 06-19-2010 11:22 AM
not able to insert kernel module ?? nishant.mishra Linux - Newbie 1 12-13-2007 03:45 AM
Load eagle-usb module at boot time (for Sagem ADSL Modem 800/840) babis85 Linux - Networking 15 05-29-2006 11:09 AM
insert module failure iansoundz Linux - General 10 07-05-2005 07:21 PM
USB module wont load!! gazzer82 Linux - Hardware 1 01-07-2004 03:07 PM


All times are GMT -5. The time now is 06:30 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration