Finally, I've built my USB NIC's driver (which uses Davicom DM9601 chip).
https://www.oesf.org/forums/index.php?showtopic=23447I added
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.
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.
# 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 ...
# 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
# 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 ...
# 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.