Low-Latency 2.4.x with ALSA mini-HOWTO

by Paul Winkler 9/11/2000 Kernel config additions by Dave Phillips 10/07/2001 updated by Patrick Shirkey 10/07/2001 updated by Eric Rzewnicki 03/03/2002

Contents

  1. Introduction
  2. Downloading and Patching the Kernel
  3. Configuring and Building the New Kernel
  4. Update Modutils and Load Modules
  5. Install ALSA
  6. Necessary Upgrades

Introduction

This document is specifically aimed at those interested in using 2.4.x with Andrew Morton's low-latency patch for audio purposes.

It's not really hard when you know what to do, but there's a lot of stuff to upgrade before you can compile and install the kernel if you are moving from 2.2.x. So if you are, don't forget to read the section on updating your system files.

Downloading and Patching the Kernel

  1. Download Andrew Morton's latest low-latency patch.
  2. Download the 2.4.x sources of the right version for Andrew's patch. When I say x, I mean for example get linux-2.4.17 if you have a Morton patch for 2.4.17. Kernel sources can be found at ftp.kernel.org and various mirrors.
  3. Remove the link /usr/src/linux (it points to your current kernel sources, probably something like /usr/src/linux-2.2.16).
    rm /usr/src/linux
    
  4. Unzip the 2.4.x source tarball and untar it in /usr/src/ . This will result in a /usr/src/linux directory. Rename this /usr/src/linux-2.4.x where x is the proper number.
    mv linux linux-2.4.x
    
  5. Re-create /usr/src/linux as a link to your new sources:
    ln -s /usr/src/linux-2.4.x /usr/src/linux
    
  6. Now apply Andrew's patches:
    cd /usr/src/
    patch -p0 < /dir/where/you/put/2.4.x-low-latency.patch
    

    This should patch without any problems.


Configuring and Building the New Kernel

  1. Configuration may be easier if you copy your old kernel configuration to your new source directory:
      cp /usr/src/linux-2.2.x/.config /usr/src/linux
      
  2. To save a copy of your old kernel config as .config.old and create a .config updated for the current kernel:
     make oldconfig
      
  3. In /usr/src/linux, do make config, make xconfig or make menuconfig (your choice). You'll want to read /usr/src/linux/Documentation/Changes first!

    Options relevant to low-latency audio:

  4. (Optional step) Edit line 4 or your kernel Makefile to set an Extraversion. I find this useful for tracking various compiles of the same kernel version in case I make a mistake or want to test different configuration options. I usually use the hostname and a sequence number in addition to indicating any patches applied:
      vi Makefile
      ...
      EXTRAVERSION = -ll-box1-0
      

  5. Now build your kernel:
      make dep
      make clean
      make bzImage
      make modules
      make modules_install
      cp arch/i386/boot/bzImage /boot/bzImage-4.x
      cp System.map /boot/System.map
      
  6. Update LILO. Edit your /etc/lilo.conf file and put in a new image entry:
    image=/boot/bzImage-2.4
            label=linux-2.4-test
            read-only
            root=/dev/whatever_you_use
     
      
  7. Now run LILO so it finds the new image:
    lilo
  8. The 2.4 kernel uses a new device file for shared memory. It's a good idea to use this, so add this to /etc/fstab. Put this line in /etc/fstab:
    none                /dev/shm              shm     defaults      0 0
    
    And make the directory: mkdir /dev/shm
    It won't affect booting your old kernel - you'll just get a complaint that the kernel does not support the shm filesystem.
  9. Finally!! Shut down and boot your new kernel.

Update Modutils and Load your Modules

There's a few things you need to do before you can load modules with 2.4.
  1. First, update modutils. Hopefully you've already downloaded the modutils package. Compile and install it now. Make sure your old modutils is gone!
  2. If your module configuration is in /etc/conf.modules, be advised that this name is deprecated - you should rename it to /etc/modules.conf . Don't worry, this won't harm anything with your old 2.2 kernel.
  3. Now you should build your kernel modules.
    cd /usr/src/linux
    make modules; make modules_install
    
  4. Try to load a module using modprobe or insmod ... hopefully it should work!

Alternative Build and Install for Debian Users

The above directions will work just as well as the following, but this method using make-kpkg can save some work for Debian users. Starting after the kernel configuration:
  1. Install kernel-package
    apt-get install kernel-package
    
  2. Build a kernel and pack it into a .deb file
    make-kpkg clean
    make-kpkg kernel-image
    
    or, if you want to time the kernel build so you'll know how long it takes if you need to do it again:
    time sh -c "make-kpkg clean; make-kpkg kernel_image"
    
  3. Install the kernel .deb package
    cd ..
    dpkg -i linux-2.4.x-ll-box1-0.deb
    
    The kernel package will take care of configuring and running LILO. It also handles the modules. For more information on the organization of kernel package management in Debian see the dpkg and make-kpkg man pages.
  4. Shut down and boot your new kernel.

Install ALSA

Now you're finally ready to get your soundcard working again. I won't go into detail on this because ALSA installation and configuration is well covered elsewhere. Go to The ALSA howto. I didn't have to do anything differently with the 2.4 kernel; ALSA just worked fine!

Necessary Upgrades

There are a number of packages you must upgrade. These are listed in /usr/src/linux/Documentation/Changes which is available here, but I will list them below too.

The Changes document notes: "...keep in mind that this list assumes you are already functionally running a Linux 2.2 kernel. Also, not all tools are necessary on all systems; obviously, if you don't have any PCMCIA (PC Card) hardware, for example, you probably needn't concern yourself with pcmcia-cs."

You should be running AT LEAST the following versions of each listed package. Higher version numbers should be fine too. I've listed test commands that can help you figure out what version you have. This is all lifted from the Changes file.

  1. Gnu C 2.7.2.3 - note that egcs 1.1.2 and above should also work. I used egcs-1.1.2-30 with no apparent problems.
  2. binutils 2.9.1.0.22
  3. util-linux 2.10g
  4. modutils 2.3.13
  5. e2fsprogs 1.18
  6. pcmcia-cs 3.1.13 (only if you have PCMCIA devices ... I don't, so I have no experience with this.)
  7. PPP 2.4.0b1
  8. isdn4k-utils 3.1beta7 (only if you need ISDN. I don't, so I have no experience with this.)

Questions, comments, corrections: Paul Winkler