Author Topic: How To Make A Usb Device's Driver Autoload  (Read 3099 times)

wellswang

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • http://wells.osall.com
How To Make A Usb Device's Driver Autoload
« on: March 21, 2007, 09:39:57 pm »
Finally, I've built my USB NIC's driver (which uses Davicom DM9601 chip).
https://www.oesf.org/forums/index.php?showtopic=23447
I added
Code: [Select]
MODULE_LICENSE("GPL v2");to solve the "kernel tainted" problem.

and add -DCONFIG_RTHAL parameter in compile command to avoid "unresolved local_irq_save/local_irq_restore" problem.
Code: [Select]
gcc -DMODULE -D__KERNEL__ -DCONFIG_RTHAL -I/usr/src/linux/include -Wall -Wstrict-prototypes -O6 -c dm9601.c
then built it successfully, no errors, no warnings.

but I don't know how to make it works and howto make it autoload when my USB NIC plugged in.

I modified /etc/hotplug/usb.usermap, and added DM9601 module in it.
Code: [Select]
# usb module         match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
dm9601          0x0003 0x0a46 0x0668 0x0000 0x0000 0x00         0x00            0x00 0x00         0x00            0x00 0x00000000

then when i plug in my USB NIC ...

Code: [Select]
# dmesg
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
usb-ohci.c: USB OHCI at membase 0xfe000000, IRQ 3
usb.c: new USB bus registered, assigned bus number 1
usb.c: kmalloc IF c2535a20, numif 1
usb.c: new device strings: Mfr=0, Product=2, SerialNumber=1
usb.c: USB device number 1 default language ID 0x0
Product: USB OHCI Root Hub
SerialNumber: fe000000
hub.c: USB hub found
hub.c: 2 ports detected
hub.c: standalone hub
hub.c: ganged power switching
hub.c: individual port over-current protection
hub.c: Port indicators are not supported
hub.c: power on to power good time: 8ms
hub.c: hub controller current requirement: 0mA
hub.c: port removable status: RR
hub.c: local power source is good
hub.c: no over-current condition exists
hub.c: enabling power on all ports
usb.c: hub driver claimed interface c2535a20
usb.c: kusbd: /sbin/hotplug add 1
hub.c: port 1, portstatus 100, change 0, 12 Mb/s
hub.c: port 2, portstatus 101, change 1, 12 Mb/s
hub.c: port 2 connection change
hub.c: port 2, portstatus 101, change 1, 12 Mb/s
hub.c: port 2, portstatus 101, change 0, 12 Mb/s
hub.c: port 2, portstatus 101, change 0, 12 Mb/s
hub.c: port 2, portstatus 101, change 0, 12 Mb/s
hub.c: port 2, portstatus 101, change 0, 12 Mb/s
hub.c: port 2, portstatus 103, change 10, 12 Mb/s
hub.c: new USB device -2, assigned address 2
usb.c: kmalloc IF c21c94c0, numif 1
usb.c: new device strings: Mfr=1, Product=2, SerialNumber=3
usb.c: USB device number 2 default language ID 0x409
Manufacturer: WK-668 USB NIC  
Product: HenTong Tech CO., LTD  
SerialNumber: 0668
usb.c: unhandled interfaces on device
usb.c: USB device 2 (vend/prod 0xa46/0x668) is not claimed by any active driver.
  Length              = 18
  DescriptorType      = 01
  USB version         = 1.10
  Vendor:Product      = 0a46:0668
  MaxPacketSize0      = 8
  NumConfigurations   = 1
  Device version      = 1.01
  Device Class:SubClass:Protocol = 00:00:00
    Per-interface classes
Configuration:
  bLength             =    9
  bDescriptorType     =   02
  wTotalLength        = 0027
  bNumInterfaces      =   01
  bConfigurationValue =   01
  iConfiguration      =   00
  bmAttributes        =   a0
  MaxPower            =  144mA

  Interface: 0
  Alternate Setting:  0
    bLength             =    9
    bDescriptorType     =   04
    bInterfaceNumber    =   00
    bAlternateSetting   =   00
    bNumEndpoints       =   03
    bInterface Class:SubClass:Protocol =   00:00:00
    iInterface          =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   81 (in)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   02 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   83 (in)
      bmAttributes        =   03 (Interrupt)
      wMaxPacketSize      = 0008
      bInterval           =   01
usb.c: kusbd: /sbin/hotplug add 2

# lsmod
Module                  Size  Used by    Tainted: P  
usb_ohci_pxa27x        21680   0  (unused)
usbcore                64176   1  [usb_ohci_pxa27x]
pxa27x_bi              24828   0  (unused)
net_fd                 25192   1
usbdcore               35464   0  [pxa27x_bi net_fd]
squashfs               31280   1  (autoclean)
mousedev                4544   1
rfcomm                 33556   0  (autoclean)
l2cap                  16384   2  (autoclean) [rfcomm]
bluez                  33188   2  (autoclean) [rfcomm l2cap]
usbdmonitor             5456   0
usb-monitor             6440   0
mmc_pxa                23856   0
sdcardmgr               1512   0  (unused)
mmc_block              24128   1
mmc_core                7928   2  [mmc_pxa mmc_block]
bvdd                   11104   0  (unused)

The dm9601.o was not loaded automatically ...
So I tried to load it manually

Code: [Select]
# modprobe dm9601
# lsmod
Module                  Size  Used by    Tainted: P  
dm9601                 13380   0  (unused)
usb_ohci_pxa27x        21680   0  (unused)
usbcore                64176   1  [dm9601 usb_ohci_pxa27x]
pxa27x_bi              24828   0  (unused)
net_fd                 25192   1
usbdcore               35464   0  [pxa27x_bi net_fd]
squashfs               31280   1  (autoclean)
mousedev                4544   1
rfcomm                 33556   0  (autoclean)
l2cap                  16384   2  (autoclean) [rfcomm]
bluez                  33188   2  (autoclean) [rfcomm l2cap]
usbdmonitor             5456   0
usb-monitor             6440   0
mmc_pxa                23856   0
sdcardmgr               1512   0  (unused)
mmc_block              24128   1
mmc_core                7928   2  [mmc_pxa mmc_block]
bvdd                   11104   0  (unused)

The driver was loaded, but it was marked with "unused" ...

and there was no new network device created ...
Code: [Select]
# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1008 (1008.0 b)  TX bytes:1008 (1008.0 b)

usbd0     Link encap:Ethernet  HWaddr 40:00:01:00:00:01  
          inet addr:192.168.0.200  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:476 errors:0 dropped:1 overruns:0 frame:0
          TX packets:300 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:76204 (74.4 Kb)  TX bytes:38968 (38.0 Kb)

I really don't know how to make this driver usable ...
I've spent 2 weeks on it ...

can anybody help me?

Thanks.

--Wells.
« Last Edit: March 21, 2007, 09:41:57 pm by wellswang »

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
How To Make A Usb Device's Driver Autoload
« Reply #1 on: March 21, 2007, 09:44:57 pm »
Probably a dumb question, but did you try loading the module and then putting the USB device in? I have no idea if it makes a difference, but it's worth the 5 seconds it would take to try.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

wellswang

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
    • http://wells.osall.com
How To Make A Usb Device's Driver Autoload
« Reply #2 on: March 21, 2007, 10:38:28 pm »
Quote
Probably a dumb question, but did you try loading the module and then putting the USB device in? I have no idea if it makes a difference, but it's worth the 5 seconds it would take to try.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=156958\"][{POST_SNAPBACK}][/a][/div]
Unfortunately, I got the same result ...
Failed again.

Anyway, thanks for your suggestion.

desertrat

  • Hero Member
  • *****
  • Posts: 743
    • View Profile
    • http://
How To Make A Usb Device's Driver Autoload
« Reply #3 on: March 22, 2007, 04:46:46 am »
Quote
and there was no new network device created ...
Code: [Select]
# ifconfig
.
.
That only shows the configured devices. It would be better to use
Code: [Select]
ifconfig -a to see all devices.
SL-C3100 / Ambicon WL1100C-CF / pdaXrom 1.1.0beta3 / IceWM

xjqian

  • Sr. Member
  • ****
  • Posts: 497
    • View Profile
    • http://
How To Make A Usb Device's Driver Autoload
« Reply #4 on: March 22, 2007, 09:53:33 am »
This is the bad sign
Code: [Select]
usb.c: USB device 2 (vend/prod 0xa46/0x668) is not claimed by any active driver
Probably something wrong with your source compilation.  Can you verify the following is the right thing to do?

Quote
add -DCONFIG_RTHAL parameter in compile command to avoid "unresolved local_irq_save/local_irq_restore" problem
My Blog | 6000L Tosa + sled | is: Angstrom | was: pdaXrom 1.1.0beta1 | was: stock 1.12 rom + no-ffpe fash kernel + X/Qt Debian |
CF GPS (FGPCFCD01) | USB "Prolific 2303" GPS (USB-UG-200) | Socket CF BT rev. H |  USB "Pegasus II" Ethernet (ADM8511) | PocketTop IR kbd | sip:527630@fwd.pulver.com
Todo: OESF wiki | stable VOIP app | usable GPS app |      Wishlist: VOIP + Bluetooth | GPS + Routing Calc