================================================================
COMPILING DRIVERS, for Linux Newbies
This text provides a very minimal introduction to compiling drivers,
particularly WinModem drivers under Linux. All points are covered in
much more detail in the Linux Kernel-HOWTO which is likely included
in the documentation set, installed within /usr/share/doc/ folders.
A necessary step is acquiring "kernel-headers" which are essential to compiling processes. Their installation or preparation varies with the Linux distribution and also KernelVersion, with KernelVersion displayed by:
uname -r
The kernel-headers are acquired in a few different ways.
A) Debian and derivative distributions - just install the kernel-headers-KernelVersion.deb, Knoppix includes them on the bootable CD.
B) SuSE with KernelVersion 2.4.21-144-* or later - install the matching kernel-source package, which does also contain the kernel-headers
C) for Fedora with KernelVersion of 2.6.6 or later, kernel-headers are coinstalled with the kernel package
D) for all other cases, the kernel-headers must be prepared from kernel-source.
The preparation can be summarised in a few steps/actions:
Install a kernel-source package representing your kernel.
Change directory (cd) into its base folder. The kernel-source in general
will match only one of several kernels that could have been installed
and NOT necessarily yours. Thus clean out any remnants of earlier usages with:
make mrproper
Copy in your kernel configuration file and have it read with:
make oldconfig
If necessary edit ONLY the fourth line of the Makefile, which completes
the specification of where drivers will be installed to (details below).
The kernel-headers are then assembelled by either:
a) for 2.4.nn kernels by
make dep
b) for 2.6.n kernels,
make bzImage
which includes an integral "make dep" step.
Whether provided by a Linux distro or assembelled from kernel-source, the sought kernel-headers are a LARGE set of FileNames.h typically located at:
/usr/src/kernel-source(or header)-KernelVersion/include/linux/FileNames.h
For some Linux Distros, the name of the Base Folder is instead:
/usr/src/linux-KernelVersion/
For more recent Redhat/Fedora releases, the location is:
/lib/modules/KernelVersion/build/
These FileNames.h are generally read during kernel and driver compiling processes.
They are text files which co-direct which code pieces are to be incorporated.
COMPILING is the process of converting human readable source code
into compact binary code that the Operating System (OS) uses most quickly.
For winmodems, code components from the modem chipset provider
are combined with KERNEL-HEADER information, thus generating one or more binary modem drivers.
They are commonly compiled as ModuleNames.o for 2.4.n kernels and ModuleNames.ko
for 2.6.n kernels. They are installed into sub-folders of:
/lib/modules/kernel-version/
Therefrom they can be dynamically inserted into the boot kernel of the
Operating System (OS) when needed, sometimes with auxiliary instructions from
/etc/modules.conf for 2.4.n kernels, and
/etc/modprobe.conf for 2.6.n kernels
Modules can be removed from the kernel when there service is over,
thus economizing on System resources.
With kernel_headers first acguired, the modem driver compilation and installation
proceeds within its own resource package, with the included README providing these details.
Quite commonly there are only three commands like:
make clean
make DriverName
make install
which will compile the drivers and install them properly.
The remainder of this text just expands on these issues and steps,
with more "theoretical issues at the end.
Modem related resources may or may not have been installed during the primary Linux installation,
as WinModem hardware is often NOT recognized. Search your Distro's package
descriptions for "modem" to reveal the status of related resources. Read
the package description to determine whether pre-compiled modem drivers were provided.
RESOURCES of a few types are needed to get on line. Do PREFERABLE use your System's
package maintenance system for the installation. This should guarantee that
any DEPENDENT packages will be called into the installation process. As a preliminary
1) Install your distributions package providing the KPPP, WVDIAL and MINICOM dialer utilities.
Dependencies within such packages will also drive the unpacking of ppp related modules
from compressed to a functional form :
module.o.gz --> modules.o
or for 2.6.n kernels
module.ko.gz --> module.ko
In addition these dialers will later aid testing and configuration,
which is to be performed only AFTER, the modem's drivers are installed.
2) Download if necessary and modem driver package specific to your modem hardware.
3a) Install your distrbution's kernel-source package, necessary for preparing kernel-headers.
Or for Debian style distributions,
3b) install the kernel-header-2.6.11.4-20a-default.deb package matching your kernel version 2.6.11.4-20a-default.
The KERNEL-HEADERs have FileNames.h can can be read with a text browser.
There is always a SMALL set or FileNames.h installed to
/usr/include/
that are needed to support diverse functions.
However the /usr/include/FileNames.h collection are TOO FEW to support compiling,
A KERNEL-SOURCE package must more generally be installed, if a full kernel-header set
is not otherwise provided. Kernel-source packages are now some 30-40 MB now even in compressed form.
The package provided by your Linux Distro SHOULD preferentially be used.
It will usually have some differences from that initially released at
http://www.kernel.org .
Typically the installation process will set two symbolic links:
/lib/modules/2.6.11.4-20a-default/build --> PATH_to/kernel-source-version/
/usr/src/linux --> PATH_to/kernel-source-version/
These latyer enable access to the kernel-headers needed during the modem driver compiling. Check with:
ls -l /lib/modules/2.6.11.4-20a-default/build
ls -l /usr/src/linux
The former link is more usefull for Systems with alternative boot kernels,
and is mandatory for some modem compiler packages.
HIGHLY IMPORTANT: the kernel-source as installed in generally does NOT
represent your current kernel version, EVEN if the kernel-version is the same.
Only one of several possible kernels was installed on your System,
and the unpacked kernel-source need NOT represent it exactly!!!
For example, in the RedHat Distro there is a set of kernel-configuration files within
/usr/src/linux/configs/
Each is specialized for a different CPU (i586, i686, K6, etc),
Yet each will be represented by the VERY SAME version name: "uname -r" .
!!!! Thus a PROPER CONFIGURATION MUST BE DONE by You, before compiling drivers !!!!
Examples provided below are partially customized from your System settings.
CONFIGURATION is started by moving into the kernel-source folder with one of:
cd /lib/modules/2.6.11.4-20a-default/build
cd /usr/src/linux
There is a Makefile on your System at: /lib/modules/2.6.11.4-20a-default/build/Makefile
with first few lines:
VERSION = 2
PATCHLEVEL = 6
KERNELSRC := ../../../linux-2.6.11.4-20a
For your current kernel, the fourth line should be
EXTRAVERSION = -.4
where -.4 has been read from your current kernel version: 2.6.11.4-20a-default.
But it this does not match what is Actually in the Makefile,
then it represents a Different kernel-header set then that of your kernel!!!
For Mandrake Linux their will generally be an included "mdk", such as:
EXTRAVERSION = -3.1mdk
SuSE 9.0 had:
EXTRAVERSION = -99-default
The first four makefile lines specify that:
a) the compiled kernel modules/drivers will have encoded version labels such as:
2.4.21-3.1mkd OR 2.4.21-99-default
b) such modules including modem drivers are installed into sub-folders of
/lib/modules/2.4.21-3.1mkd/
/lib/modules/2.4.21-99-default/
The major points are that compiled drivers must be both
kernel-release (the 2.4.21) AND EXTRAVERSION matched with the installed kernel.
Otherwise they may be installed uselessly and not be detected by the kernel
OR there will be a failure upon attempted insertion, with message including:
a list of "unresolved symbols ".
Kernel-headers may be resident from a prior usage of the kernel-source/.
Check with:
ls include/linux/
which may display abundant FileNames.h
The version of these headers will be in the UTS line displayed by
cat include/linux/version.h
#define UTS_RELEASE "2.4.21-3.1mdk" (as an example)
Next, list completely the contents of the kernel-source with:
ls -a
Where the " -a " additionally reveals ".dot-prefixed-confguration-files" such as
.config .hdepend .depends
which may be left over from the prior usage of the kernel-source. Below is an example:
-------------------
.config .hdepend .depends
COPYING Makefile Rules.make init mm
CREDITS README arch drivers ipc net
Documentation conf.vars fs kernel scripts
MAINTAINERS REPORTING-BUGS crypto include lib
Configuration of the kernel-source is where almost all the Mistakes occur!!!
Here is a way to do it correctly (but read through EXCEPTIONAL CASES below).
1)Within kernel-source/ folder, browse the README file for general guidance.
It will relate that the command:
# make mrproper
cleans up leftovers from any previous usage .dot-files and the include/linux/ folder.
Additionally you may need to do an edit within Makefile, but ONLY that 4th line.
2) If necessary to edit, FIRST make a backup:
cp Makefile Makefile.backup
then edit ONLY the 4th line of Makefile to match the EXTRAVERSION of 2.6.11.4-20a-default
EXTRAVERSION = -
NEVER change anything else within the Makefile.
3) Set the dependencies of the current kernel.
For SuSE 9.0 and later, there is a command which does the following steps
# make cloneconfig && make dep
Also browse the excellent README.SuSE in the kernel-source/ folder
For other Distros, the following steps are necessary, within the kernel-source/ folder
copy the kernel-config file to .config
and DO SPECIFY that " . "
But where is it? For many Distros, it will be the file like
/boot/config-2.6.11.4-20a-default
matching the output of:
uname -r
Or it may be the target of a symbolic link: /boot/config -->
So
cp /boot/config-2.6.11.4-20a-default .config
For SuSE 8.0 and earlier versions it is:
cp /boot/vmlinuz.config .config
PLEASE do not omit that "." in .config as it is crucially necessary.
View .config with a text browser.
It is simply a listing of the code components used in the kernel and its modules:
#
# Automatically generated make config: don't edit
#
CONFIG_X86=y
# CONFIG_SBUS is not set
CONFIG_UID16=y
etc.
4) The .config file will be read during
# make oldconfig
which feeds its specifications through a process specifying
the SAME inter-dependencies previously used in compiling your kernel,
and may generate additional .dot-config files . They can be displayed with:
# ls -al
5) Though it may be redundant after "make mrproper", it will do no harm to:
make clean
5a) For the SuSe Linux versions 8.0 and previous , there will exist files:
/boot/vmlinuz.autoconf.h
/boot/vmlinuz.version.h
They MUST be copied as:
cp /boot/vmlinuz.autoconf.h /usr/src/linux/include/linux/autoconf.h
cp /boot/vmlinuz.version.h /usr/src/linux/include/linux/version.h
6) Now build kernel-headers with:
make dep
for 2.4.n kernels or for 2.6.n kernels
make bzImage
during which you can walk your dog, take a shower, have tea, etc.
7) Check for resultant FileNames.h with:
ls include/linux/
and
cat include/linux/version.h
to verify the version.
COMPILING the MODEM DRIVERS can now finally be done.
Unpack the compiler kit for your modem drivers,
cd into its folder, read any README or INSTALL files,
make clean
FINALLY, your modem drivers will compiled by a command like
make OR make ModuleName
or perhaps
make all
During this process, some of the kernel-header code with be joined
with the supplied modem specific code, and ModemDrivers.o will be produced.
Follow and further instructions in the modem code resource
to install the drivers, often with:
make install
THEORETICAL ISSUES
WinModem driver packages commonly include:
1) a readible Open Source component, which can be readily debugged by
experts in code. This component provides "wrappers" to common
kernel functions for an already complied, or BINARY format, component of the modem code.
2) A Closed Source component compiled into the binary form, in which
proprietary information is encrypted. This will include the copyrighted Vn.nn compression algorithms.
In 2004, pre-compiled modem drivers are beginning to be included
for a few winmodems by some Linux distributions.
But the binary format precludes incorporation of the modem drivers in some Linux distributions
for legal reasons, practical reasons, and/or reasons of principle.
Since almost all the newer PCs are now equipped with WinModems,
many users will have to compile their own linux modem drivers.
Exceptions are the more expensive modems with Controller chipsets,
characteristic of the earliest modems.
They are supported by Open Source serial code included in Linux
distributions (Distros hereafter).
Winmodems are less expensive because of greatly reduced hardware costs.
They lack Controller chips of the earliest modems, and may additionally lack Digital Signal Processor (DSP) chips of second generation modems.
Functions of Controller based chipsets are replaced by a combination of
software code and/or other System hardware.
Modems without a controller chip are referred to as "controllerless modems" and
modems lacking both a DSP and controller chips are referred to as "soft modems".
With faster central processor units (CPU), some processing tasks are performed
by the CPU for the controllerless modems. The CPU does nearly all
the signal processing for the "soft modems" lacking a DSP.
AC97 or MC97 soft modems conform to an ac97_codec, and can host a variety of Subsystems It is the CODEC of the Subsystem which determines which software should be utilized!!
and any modem controllers can host one of a variety of soft modem Subsystems.
There are additionally soft PCI modems without such controllers, which still utilize
the common ac97_modem.o driver. In general it will be YOUR task to identify
the Subsystem codec and compile the needed driver.
## end Modem/DriverCompiling.txt