Driver disk

Petr Sulla sulla na ite-web.de
Pátek Říjen 12 08:44:36 CEST 2001


> Prosím o typ, kde se docist, jak vytvorit vlastni driver disk pro
instalaci
> (konkretne RH 6.2).

Tady je howto, ktere jsem si sesmolil a jeste ho nikdo nevidel ;) Nektere
veci mozna pujdou udelat jednodusseji.
Doufam, ze pomuze.

S pozdravem
                        Petr Sulla
----------------------------------------------------------------------

How to build a custom RedHat Linux driver disc
----------------------------------------------
2001, Petr Sulla, xsulla na fi.muni.cz

Disclaimer
----------
RedHat doesn't provide ANY information about the driver disc (at least
I couldn't find any). I found out all information written here by
myself and from various sites on the Net and can't guarantee it's
correctness. Please notify me, if it's buggy, if it's total nonsence ;)
or if there's an easier way to do it.

It worked for me, it also could work for you.
Don't blame me if it doesn't.

Motivation
----------
Imagine the following situation - you have a device, that is critical
for installing RedHat Linux on a computer. This device is not supported
by the kernel used by the installer. A good example is a RAID
controller, eg. the Mylex AccelRAID 170 in RH 7.0.
Now you are in a BIG trouble ;)

There are two ways to install RedHat Linux on such a computer:

a) temporarily attach a supported device, install Linux on it, compile
the kernel with support for your device, copy ...
b) build a driver disc

Since the option a) is not always the easy or possible way to go, we
will further investigate the option to build a custom driver disc.


Structure of the driver disc
----------------------------
We will use the Mylex AccelRAID 170 SCSI controller with a RAID5 array
as an example and we try to install RH 7.0 on it.

The driver disc is a floppy with MSDOS file system.
Mount it and list the files.

]# mount /dev/fd0 /mnt/fd0 -t msdos
]# ls -l /mnt/fd0

You should see something like this:
-rw-r--r--    1 root     root         4327 Aug 31  2000 modinfo
-rw-r--r--    1 root     root       766526 Aug 31  2000 modules.cgz
-rw-r--r--    1 root     root          538 Aug 31  2000 modules.dep
-rw-r--r--    1 root     root         2244 Aug 31  2000 pcitable
-rw-r--r--    1 root     root           21 Aug 31  2000 rhdd-6.1

I try to explain what all the files mean and how to create them.

modinfo
-------
Contains information about avaliable modules and their parameters.
It looks like this:

Version 0
3c501
        eth
        "3Com 3c501"
        io "Base I/O address"
        irq "IRQ level"
aha1542
        scsi
        "Adaptec AHA-154x and 631x-based"

My guess is this:
3c501 etc.     - name of the module
eth, scsi etc. - type of the device
"3Com 3c501"   - name of the device to be shown to the user
io, irq etc.   - name of module parameters to be entered by the user
                 and their description

In my case, I created a file containing the following lines:

Version 0
DAC960
        scsi
        "Mylex AccelRAID 170"

modules.cgz
-----------
This is probably the most difficult to create file.

It contains packed module files.
It's a gzipped cpio archive. You can copy it to your
harddrive and then decompress it by using

]# zcat modules.cgz | cpio -id

It contains a single directory with the name of the kernel version used
by the installer, eg. 2.2.16-22BOOT for RH 7.0.
This directory contains all the modules like 3c501.o etc.

Making your own modules.cgz
~~~~~~~~~~~~~~~~~~~~~~~~~~~
You need to get the source for your device's driver and compile it
as module. You of course need another computer with Linux for this.

When you are going to build the module, you must get EXACTLY the same
kernel, that is used by the installer and compile the driver as module
using this kernel.

You can get this kernel by installing kernel-source*.rpm or by getting
the appropriate version eg. from ftp.kernel.org.

Then you have to change the kernel version in /usr/src/linux/Makefile
with EXTRAVERSION=-subsublevelBOOT, eg. EXTRAVERSION=-22BOOT for the
2.2.16 kernel in RH 7.0. The compiled kernel will then have version
2.2.16-22BOOT. The version must EXACTLY match the kernel version used
by the installer.

In my case I needed to get the 2.2.16 kernel (used in RH 7.0) and the
updated driver DAC960.

Install your device driver source to the kernel sources, then configure
the kernel, select the driver as module and make the modules (you can
install them as well, so you can better find the compiled module).

Then create a directory having the same name as your kernel version,
eg. 2.2.16-22BOOT for RH 7.0. Copy the compiled module (eg. from
/lib/modules/2.2.16-22BOOT) to this directory.  In my case it was
the file DAC960.o. Then you can create the modules.cgz out of this
directory. You can do it this way:

]# ls -1 2.2.16-22BOOT/*.o | cpio -Hcrc -o | gzip -9 > modules.cgz
(you must be in the directory containing the 2.2.16-22BOOT directory)

Just to make things even clearer: as you probably have guessed, there
could be more directories named after different kernel versions
containing the module, that could be placed in modules.cgz. The driver
disc could be then used in all RedHat Linux distributions. There's even
a module development kit from RedHat containg kernel headers to all
kernel versions used by RedHat installers, which allows to compile the
module for all RedHat Linux distributions (I didn't try it).

modules.dep
-----------
Contains information about module dependencies, ie. what other modules
a module needs. It looks like this:

parport_pc: parport
3c503: 8390
plip: parport_pc

I think it's quite selfexplanatory. In my case, I left this file blank,
because DAC960 requires no other modules.

pcitable
--------
Contains vendor and device numbers of PCI cards and their appropriate
device drivers. The PCI devices are identified by their vendor and
device numbers, so it's important to enter them. The file looks like
this:

0x0e11 0x0508 "sktr"     "Compaq|Netelligent 4/16 Token Ring"
0x0e11 0xb060 "cciss"     "Compaq|Smart Array 5300 Controller"
0x1000 0x0701 "yellowfin" "Symbios|83C885"
0x1000 0x0702 "yellowfin" "Symbios|Yellowfin G-NIC gigabit ethernet"
0x1011 0x001a "acenic"    "Farallon|PN9000SX"

where the items have this meaning:
vendor no., device no., driver name, description.

You have to find out the PCI vendor and model numbers for your
device. This is quite easy, because you just have to boot the machine
with some one-floppy distro (like tomsrtbt) and then cat the /proc/pci
file or run the lspci utility from pciutils.

In my case, the pcitable file looked like this:
0x1069 0x0050 "DAC960" "Mylex AccelRAID 170"

rhdd-6.1
--------
Contains a single line:
Supplemental Drivers

Well, there must be a way to identify the driver disc ;)


How to build and use the custom driver disc
-------------------------------------------

Just format a floppy with the MSDOS file system using

]# mkdosfs /dev/fd0

Then create all the files as described above and copy them to
the floppy. That's all.

When installing, choose the 'linux dd' installation (have a driver
disc). Insert the disc when you are asked to. If you did everything
right, you can choose the correct driver and/or the installer
recognizes your device and loads the driver.

Good luck !

Links
-----
http://www.tunl.duke.edu/~canon/linux/add_driver.html





Další informace o konferenci Linux