Compiling a Device Driver Module

In many cases drivers compiled for similar kernel versions will work. Pre-compiled modules in the form of RPMS for popular distributions are frequently available. If a pre-compiled module is not available; you'll have to compile one from the driver source code, or the source code RPM (SRPM).
* Verify that the source code for your current kernel version is installed.
* If you don't have a /usr/include/linux/version.h file, do cd /usr/src/linux; make include/linux/version.h
* Copy the driver source code to a source directory
* Compile the file using the compile-command at the bottom of the driver source file. If a compile-command is not there use the following compile command:

gcc -DMODULE -D__KERNEL__ -O6 -c driver.c

* As 'root', test the module by doing "insmod driver.o".
* Install the driver module in the proper location for your distribution. This is usually /lib/modules/kernel-version/net/driver.o. The command to do this is
install -m 644 driver.o /lib/modules/`uname -r`/net/

Testing the New Module

As 'root', load the module using "insmod driver.o" and execute the appropriate 'route add -net ...' for your local network.
If the networking works correctly, add the module to your system configuration. For Slackware and most other systems, add the insmod command to /etc/rc.d/rc.inet1 or /etc/rc.d/rc.local. RedHat users should add the insmod line to /etc/rc.d/rc.modules or copy driver.o to /lib/modules/`uname -r`/net/ and add the following line to /etc/conf.modules:

alias eth0 driver

Consider the following command "/sbin/insmod driver.o full_duplex=1,0,1". This command sets the full_duplex flag for the first and third cards of this type.
To set module parameters when the module is loaded automatically, add the following line to /etc/conf.modules

alias eth0 driver

options driver full_duplex=1,0,1 debug=0 be contd. ;)

Page copy protected against web site content infringement by Copyscape

1 comment:

Kevin said...

compiling the Source RPM drivers was really a gud work....Testing 1 i still have to work on it...cheers...