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
- Introduction
- Downloading and Patching the Kernel
- Configuring and Building the New Kernel
- Update Modutils and Load Modules
- Install ALSA
- 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
- Download Andrew Morton's latest low-latency
patch.
- 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.
- 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
- 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
- Re-create /usr/src/linux as a link to your new sources:
ln -s /usr/src/linux-2.4.x /usr/src/linux
- 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
- 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
- To save a copy of your old kernel config as .config.old and create a .config updated for the current kernel:
make oldconfig
- 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:
- If you have IDE drives, go to the "IDE, ATA and ATAPI
Block devices" section and say Yes to "Generic PCI
bus-master DMA support" and "Use PCI DMA by default when
available". This will turn on DMA for your disks which is
necessary for low-latency disk-intensive work. You may also
want to browse this section for any options related to your
specific motherboard/chipset.
-
Next, go to the "Character devices" section and enable
"Enhanced Real-time Clock Support" for access to your
computer's hardware clock.
-
Turn on sound support. If you want to use the ALSA drivers,
enable sound support as a module but don't select anything
else; otherwise, select the modules that work for your
particular soundcard.
-
Finally in the "Kernel Hacking" section, I suggest saying
Yes to "Magic SysReq Key". This should give you a way to
kill runaway processes, or reboot cleanly if all
else fails. What can happen is that a DSP process is hogging
the CPU with maximum realtime priority so you can't even interact
with a shell to kill it. Well-designed applications
should have safeguards against this, but you need
ammunition for emergencies, especially when working with
software in early development.
Read /usr/src/linux/Documentation/
sysrq.txt for instructions;
more importantly, PRINT IT since you won't be able to get at
the file when you need it most!!!
If you forget to print it Alt-SysRq-q might help you. q is
currently not a valid sysrq key so using it causes sysrq
to print a usage message with a list of the available commands.
The appropriate letter for each is given in uppercase. This is a
simple "cheat sheet" I've used in the past when I can't find my
printed copy of sysrq.txt. This may not work in the future if
q becomes used by sysrq.
I've found that when something gets stuck, Alt-SysRq-e
(which sends a "sigterm all" signal) will kill everything
and drop me back to a login prompt so I don't even have to reboot.
- (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
- 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
- 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
- Now run LILO so it finds the new image:
lilo
- 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.
- 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.
- First, update modutils. Hopefully you've already downloaded the
modutils package. Compile and install it now. Make sure your old
modutils is gone!
- 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.
- Now you should build your kernel modules.
cd /usr/src/linux
make modules; make modules_install
- 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:
- Install kernel-package
apt-get install kernel-package
- 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"
- 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.
- 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.
- 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.
- binutils 2.9.1.0.22
- util-linux 2.10g
- Test commands:
chsh -v
rpm -q util-linux
dpkg -l util-linux
- Where to Get It: http://www.il.kernel.org/pub/linux/utils/util-linux/
- I have not been able to install an RPM for any version above
2.10f-7. I did find an RPM for 2.10m here,
but it depends on an upgrade of glibc-2.2 that I don't want to do (rpm
complains of so many dependencies that I've given up).
I was able to compile and boot 2.4.0-test6 with 2.10f-7, but you
may want to compile and install the latest yourself. Note that this is
dangerous - you MUST carefully
read the MCONFIG file and make sure everything's right. I tried to
compile it and didn't know
what I was doing, and I made it impossible to log in to my
system!! After some hairy battling with broken boot floppies, I
managed to get my system working again. The 2.10f-7 rpm seems to work
for me so I went back to that.
I have had one bit of mysterious trouble - Netscape seems to have become
immune to kill, even kill -9;
kill is part of util-linux, so I suspect something's funny there.
- modutils 2.3.13
- e2fsprogs 1.18
- pcmcia-cs 3.1.13 (only if you have PCMCIA devices ... I
don't, so I have no experience with this.)
- Test commands:
cardmgr -V
- Where to Find It: ftp://sourceforge.org/pcmcia/
- PPP 2.4.0b1
- isdn4k-utils 3.1beta7 (only if you need ISDN. I don't, so
I have no experience with this.)
Questions, comments, corrections: Paul Winkler