======================================================= COMPILING DRIVERS, for Linux Newbies Within the workshop there is an instruction set, the Makefile, and a few tools. You command: make clean An elf named "make" comes in, reads Makefile and then cleans up any debris of previous efforts. Do ALWAYS command "make clean" as a first step before new driver compilations. The major work of compiling drivers and any associated tools is commanded with: make or perhaps make DriverName There only remains to command installation of the modem driver(s) and tools with: make install Configuration of a dialout utility is done elsewhere, and you can access the Internet. It is really that simple, once the workshop with tools has been prepared. But new drivers have to be compiled with every operaing system update. The remainder of this text is thus aids you in the preparations, dealing with a variety of special cases. Most points are covered in much more detail in the Linux Kernel-HOWTO, likely included among the HOWTO documentation set installed within /usr/share/doc/ folders. The core operating system of a PC is comprised of a motherboard, the software kernel, and its auxilliary code modules. The kernel is the file /boot/vmlinuz-2.6.27-11-generic. Modules located in subfolders of /lib/modules/2.6.27-11-generic/ . They can be inserted into or removed from the acting kernel upon demand. This provides adaptablity to the diverse hardware components of PCs and changing requirments. Modem drivers are one type of module. As contrasted to most Linux software, modem driver codes have some non-public code components. That is the drivers are not fully Open Source, to protect Intellectual Property of the providing companies. This has a consequence that many Linux distributions will not or cannot legally supply proprietary modem drivers. Rather the Users must get the modem code package and direct compiling of the code and driver installation. A complementary resource for compiling is a family of FileNames.h, collectively called kernel-headers. They are both code bits themselves and also call for other code bits their functioning depends on. Depending on the Linux distribution, kernel-headers may not be automatically installed. If not they will always be made available on installation media or some Linux repository. They can be searched for by package names including: kernel-source, linux-source, kernel-headers and 44 There are always some kernel-headers in afolder /usr/include/. But these are an INCOMPLETE, too small collection and DO NOT suffice for compiling processes. In addition some software utilities may have to be installed. The instructions for compiling are read by make. A set of compiler tools are installed as a gcc-SomeVersion package. After compiling, the various pieces and linked dynamically together with "ld". Together wiith some simpler software tools, the ld will already be installed on Linux systems. Systems using the Debian style maintanence system additionally require a package "kernel-kbuild-3.n" to properly utilize kernel-headers or 2.6.n kernels. The "kernel-headers" are matched with an installed kernel, or must be generated from a kernel-source package. These are provided in different ways by the various Linux distributions, under 2.6.n kernels: Redhat and Fedora - installation is coincident with kernel installation, with placement of the kernel-header base folder in /lib/modules/2.6.27-11-generic/build/ Mandrake and SuSE/Novell - installation as part of a kernel-source or linux-source packages, with location at /usr/src/kernel-headers-2.6.27-11-generic or /usr/src/linux-2.6.27-11-generic Debian and distros using its Package.deb format have names: kernel-headers-2.6.27-11-generic linux-headers-2.6.27-11-generic for Ubuntu and installation is into /usr/src/ for Xandros, there is a xandros-kernel-source-version.deb which has to be installed Unpack if necessary with # cd /usr/src/ # ls # tar jxf xandros-kernel-source-version.tar.bz2 see http://support.xandros.com/kb-view.php?topic=64 for details but for 2.6.n kernels, the step after: # make EXTRAVERSION=-x1 oldconfig should be # make EXTRAVERSION=-x1 bzImage Others - ??? For the prior generation of 2.4.n kernels, there are special cases. Skip this if your kernel is a 2.6.n or a Debian type. For RPM using distros, the kernel-source-2.6.27-11-generic or linux-source-2.6.27-11-generic packages must be installed and configured as described below: 1) SuSE with KernelVersion 2.4.21-144-* or later - install the matching kernel-source package, which does also contain the kernel-headers; 2) for Fedora II or later, kernel-headers are/were coinstalled with the kernel package; 3) for all other cases of 2.4.n kernels, 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. 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 if necessary your distrbution's kernel-source package, necessary for preparing kernel-headers under 2.4.n kernels Or for Debian style distributions, 3b) install the kernel-header-2.6.27-11-generic.deb package matching your kernel version 2.6.27-11-generic. A KERNEL-SOURCE package must 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.27-11-generic/build --> PATH_to/kernel-source-version/ /usr/src/linux --> PATH_to/kernel-source-version/ These later enable access to the kernel-headers needed during the modem driver compiling. Check with: ls -l /lib/modules/2.6.27-11-generic/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.27-11-generic/build cd /usr/src/linux There is a Makefile on your System at: /lib/modules/2.6.27-11-generic/build/Makefile with first few lines: VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 27 EXTRAVERSION = .10 NAME = Trembling Tortoise # *DOCUMENTATION* For your current kernel, the fourth line should be EXTRAVERSION = where has been read from your current kernel version: 2.6.27-11-generic. 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.27-11-generic 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.27-11-generic matching the output of: uname -r Or it may be the target of a symbolic link: /boot/config --> So cp /boot/config-2.6.27-11-generic .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/DOCs/DriverCompiling.txt