Configuring a Kernel for USB Support

Note, this chapter is somewhat out of date as the kernel has evolved quite a bit in the last year and a half. In fact, you should not have to venture into building your own kernel unless your OS provider is seriously behind the times. With that said, there is still much valuable information here that you can use if you must build your own system.

General

Apcupsd version 3.10.5 provides support for USB UPSes on Linux systems. However at this time (February 2003) Linux kernels do not yet support the HIDDEV device that is used by apcupsd. If you are running a release such as RedHat 7.3 or 8.0, the kernels generally come preconfigured with all the necessary patches. If you are not so fortunate but you have a kernel version 2.4.5 or later and you apply the appropriate Alan Cox patch, you will be able to enable USB support in apcupsd.

For kernel 2.4.5, you need patch ac12 or later. For later versions of the kernel, any ac patch should work. Please be sure to obtain either the latest kernel or the one shipped with your system. We use version 2.4.5 for illustration purposes and do not recommend that you downgrade to it.

Downloading

New kernel versions are released and an amazing speed, so by the time you read this, the current stable kernel will no longer be 2.4.5 and you should obtain the version that corresponds to current usage or to what you already have on your system. You can obtain the 2.4 kernels from: http://www.kernel.org/pub/linux/kernel/v2.4/.

You can obtain the Allen Cox patches from: http://www.kernel.org/pub/linux/kernel/people/alan/2.4/

Alternatively, you can obtain the latest kernel source from your favorite vendor. For example, for RedHat, you would obtain: kernel-source-2.4.x.rpm and install it with rpm, then skip the first two steps in the next section.

Building the Kernel

I provide here only a very brief explanation of the steps necessary to build your kernel. If you have a later kernel such as RedHat 7.3 (kernel 2.4.18-5), you don't need to rebuild it. If you want to anyway, you can install the kernel-source rpm, cd to the appropriate directory (usually /usr/src/linux-2.4), then skip immediately to step 11 below.
 1. Download kernel from:
    http://www.kernel.org/pub/linux/kernel/v2.4/
    (I assume you get linux-2.4.5.tar.gz and that
     you put it into /usr/src)

 2. Download Alan Cox patch from:
    http://www.kernel.org/pub/linux/kernel/people/alan/2.4/
    (I assume you get patch-2.4.5-ac12.gz and that you
     put it into /usr/src)

 3. su root

 4. cd /usr/src

 5. Ensure that the directory linux does not exist,
    or if it is linked, remove the link or change the
    name.

 6. Unpack the kernel with:

    tar xvfz linux-2.4.5.tar.gz                 

 7. Unpack the patch with:

    gunzip patch-2.4.5-ac12.gz

 8. Move the kernel source into a different directory:

    mv linux linux-2.4.5
        
        or
        
        mv linux linux-2.4.5-ac12
 
 9. cd linux-2.4.5

10. Apply the patch with:

    patch -p1 <../patch-2.4.5-ac12

    There should be no errors.

11. make mrproper

12. Find a valid configuration file, and
    make sure it has the following configuration
        statements. If not, please add them:
        
    CONFIG_USB=m
    CONFIG_USB_LONG_TIMEOUT=y
    CONFIG_USB_LARGE_CONFIG=y
    CONFIG_USB_HID=m
    CONFIG_USB_HIDDEV=m

    Note, the CONFIG_USB_LARGE_CONFIG does not seem to be present
    in some of the later kernels (e.g. 2.4.18)

    Note, apparently in later kernels the CONFIG_USB_HIDDEV should
    be set to CONFIG_USB_HIDDEV=y (at least our users report this,
    I suspect it may depend on the setting you use for CONFIG_USB, in
    any case, please note to get this stright).

13. make menuconfig  or   make xconfig (if you are running X)
    load a valid configuration file
    check the above values and ensure they are correct
    save config

14. Check what you saved by editing .config
    You can skip this if you have done kernel builds
        before.

15. make dep

16. make clean

17. make bzImage

18. make modules

19. make modules_install

20. make install

21. If you boot from a SCSI, you will need to make a
    new initrd image

22. Update /etc/lilo.conf to include the new kernel.
    If you are using grub, edit the /boot/grub config
    file and skip steps 24 and 25.

23. cd /etc  (skip this if you are using grub)

24. lilo -v  (skip this if you are using grub) 

25. reboot

26. Ensure that uhci and hid are loaded by
    doing cat /proc/modules
        
        If not, load them by hand.
        
        modprobe uhci
        modprobe hid

Build Problems

If you start with the RedHat kernel-source package as I did and use one of their config files in configs as I did, you are very likely to get a number of undefined symbols when making or installing the modules. In this case, I found that I can simply edit .config with my favorite editor, comment out modules that don't build (knowing which ones is not always obvious from the names), then simply make modules and make modules_install until all the problems go away. Once the module build and install is correct, I recommend doing make bzImage and make install again.

Disclaimer

I'm not at all a kernel expert so you are pretty much on your own here. Any corrections to these instructions would be welcome.
Back Next Home