Adding a Device Driver

5.10. Adding a Device Driver

This section describes how to add a device driver to the installation environment (initrd.img). This enables the installation environment to use the new driver as well as installing the device driver into the running environment (that is, after the node has installed).

This feature is enabled by the ddiskit package created by John W. Linville at RedHat.

  1. Set up a build environment:

    # cd /tmp
    # cvs -d:pserver:[email protected]:/home/cvs/CVSROOT login

    This will ask for a password. No password is required, just enter an empty password.

  2. Now get the Rocks core development environment and the Kernel Roll development environment:

    # cvs -d:pserver:[email protected]:/home/cvs/CVSROOT checkout -r ROCKS_4_2 rocks-devel
    # cvs -d:pserver:[email protected]:/home/cvs/CVSROOT checkout -r ROCKS_4_2 rocks/src/roll/kernel
  3. Go to the directory which holds the device driver code:

    # cd /tmp/rocks/src/roll/kernel/src/rocks-boot/enterprise/4/images/drivers
  4. In this directory, you'll see some example drivers. Let's look at the e1000 driver:

    # cd e1000
  5. If you want to supply a new version of the driver, you'll have to download the e1000 source tarball and copy the *.c and *.h files from the tarball to this directory. Make sure all the *.c and *.h files are listed at the top of the Makefile:

    MODULES := e1000
    
    SOURCES := \
            e1000_ethtool.c \
            e1000_hw.c \
            e1000_main.c \
            e1000_param.c \
            kcompat.c \
            kcompat_ethtool.c
    
    HEADERS := \
            e1000.h \
            e1000_hw.h \
            e1000_osdep.h \
            kcompat.h
  6. You'll need to make sure the proper PCI ids are in the file pcitable. For example, to test on one of our Dell SC1425's, we added the line:

    0x8086  0x1076  "e1000" "Intel|82541GI/PI Gigabit Ethernet Controller (rev 05)"
  7. Now we'll need to specify to the device driver building code that the e1000 driver should be built. To do this, edit the file subdirs:

    # cd ..
    # vi subdirs
  8. Change the section from:

    #
    # put a list of all the driver directories that you'd like to build.
    #
    # for example, to build the 'e1000' driver, uncomment the line below:
    #e1000

    to:

    #
    # put a list of all the driver directories that you'd like to build.
    #
    # for example, to build the 'e1000' driver, uncomment the line below:
    e1000
  9. Build the rocks-boot package:

    # cd /tmp/rocks/src/roll/kernel/src/rocks-boot
    # make rpm
  10. When this completes, copy the binary RPMs into a directory where the distribution building utility (rocks-dist) will find and include them:

    # cp /tmp/rocks/src/roll/kernel/RPMS/x86_64/rocks-boot* \
    	/home/install/contrib/4.2/x86_64/RPMS/

    Note

    If you are building on an i386 system, change the above x86_64 references to i386.

  11. Rebuild the distro:

    # cd /home/install
    # rocks-dist dist
  12. Install the newly created initrd.img and its matching kernel vmlinuz so PXE booted nodes will get the new device drivers:

    # cd /home/install
    # rpm -Uvh --force rocks-dist/lan/x86_64/RedHat/RPMS/rocks-boot-4*.rpm
    # cp /boot/kickstart/default/initrd.img /tftpboot/pxelinux/
    # cp /boot/kickstart/default/vmlinuz /tftpboot/pxelinux/
  13. Now PXE boot a node. This node will load your new driver and will install this driver into the running environment.

5.10.1. Adding a New Device Driver (That Isn't One of the Example Drivers)

If the name of your device driver you wish to add is not one of the example device drivers (e.g., ata_piix, cciss, e1000, sk98lin, or tg3), then you'll need to create a new directory and populate it with the appropriate files.

For example, let's say your new device driver is called fa and it is a network device driver.

# cd /tmp/rocks/src/roll/kernel/src/rocks-boot/enterprise/4/images/drivers
# mkdir fa
# cd fa
# cp ../e1000/modinfo .
# cp ../e1000/Makefile* .
# cp ../e1000/modules.dep .
# cp ../e1000/pcitable .

You'll need to edit modinfo, modules.dep and pcitable to match your driver. See ddiskit for details on how to properly format the files.

Then you'll need to edit Makefile to ensure all the *.c and *.h files are listed. Also, if the driver requires special flags, make sure the are appended to the last line of Makefile. For example, to add the flag -DFA_DEBUG, change the line from:

EXTRA_CFLAGS += -I$(PWD)

to:

EXTRA_CFLAGS += -I$(PWD) -DFA_DEBUG

The rest of the build process follows the same procedure as above starting at step 7 where you'll have to add fa to the file subdirs.