file: redhat-pcmcia-setup.html
date: 20 Aug 2004
Beginning with RedHat 7, Linux kernel version 2.4 became the standard kernel in the RedHat distribution. Unfortunately, some of the lesser-used memory card drivers have not been ported to the Linux 2.4 kernel drivers (see comments by David Hinds on 2.4 kernel issues with PCMCIA). Thus the default kernels from RedHat (and others) will not handle "raw" memory cards directly. Support is still available as part of the standalone PCMCIA package. This requires "tweaking" the kernel and rebuilding it, installing the latest pcmcia-cs package from sourceforge.net, then a couple of minor setup changes to RedHat startup files. This document will outline that process.
The first step is to get the latest kernel sources for your machine as well as the pcmcia-cs source. Go to redhat.com and look for the most recent kernel RPM's in the support/errata section of the site (Errata: Security Alerts, Bugfixes, and Enhancements). Download the pre-built kernel for your machine, plus the kernel-source package (NOT the kernel-version.src.rpm - you want the kernel-source-version.i386.rpm; for example, on my Dell Inspiron 8100 notebook with RedHat 9 running (in July 2003), it's kernel source kernel-source-2.4.20-18.9.i386.rpm and pre-compiled kernel kernel-2.4.20-18.9.i686.rpm
Follow RedHat's instructions for upgrading your running kernel - get this working before proceeding! Once you are happy that everything is running normally with the new kernel, you can update the kernel source package on your PC as well. If you have rebuilt your kernel before for any reason, backup any .config files you want to keep (the /usr/src/linux-2.4/ source tree will normally be replaced when you upgrade). Once you're happy about your backups, upgrade the kernel source.
Now that you have the latest kernel running, and the matching kernel source is on your machine, get the latest pcmcia-cs source package from pcmcia-cs.sourceforge.net at the downloads page. As of July 2003, the package is pcmcia-cs-3.2.4.tar.gz. Untar this in the /usr/src/ directory. An ls in the /usr/src/ directory (current as of July 2003) shows the following directories:
aragorn: /usr/src#  ls
debug/    kernelconfigs/    linux-2.4@    linux-2.4.20-18.9/   
pcmcia-cs-3.2.4/    redhat/
kernelconfigs/ is where I backed up a couple of older .config files for the linux kernel, linux-2.4@ is the symlink to linux-2.4.20-18.9, and pcmcia-cs-3.2.4 is the new pcmcia-cs source tree.
To rebuild the kernel for use with standalone PCMCIA support, you need to turn off PCMCIA support in the kernel then recompile everything. Here's how:
Now that the kernel and modules have been rebuilt, it might be a good idea to be sure you have a boot floppy available to reboot your current system if anything goes wrong in the next several steps. If you don't have a working boot floppy, make one now. See the man page for mkbootdisk for a handy way to make a boot floppy (example: if your current kernel is version 2.4.20-18.9, put a 1.4MB floppy in your drive and enter mkbootdisk 2.4.20-18.9 to create a boot disk for the running kernel).
Next update your bootloader configuration file (lilo.conf or grub.conf) to add the new kernel - DON'T remove the references to the current kernel. Add the lines for the new kernel so that you still default to the current kernel, and can choose the new kernel at boot time. Here's a typical example for grub.conf:
title Red Hat Linux (2.4.20-18.9) root (hd0,1) kernel /vmlinuz-2.4.20-18.9 ro root=/dev/hda11 hdb=ide-scsi initrd /initrd-2.4.20-18.9.img title Red Hat 9 custom (2.4.20-18.9custom) root (hd0,1) kernel /bzImage ro root=/dev/hda11 hdb=ide-scsiIf you use lilo.conf, the syntax is similar, but different; and don't forget to run /sbin/lilo after you save the new lilo.conf to actually update the boot record (there is no equivalent step for grub).
Now try rebooting to make sure everything is still working; if you kept your old kernel as default, everything should start up like always. Reboot again, and at the grub (or lilo) prompt, select the new kernel. Again, everything (except PCMCIA) should start up normally. Fix any problems BEFORE proceeding. When you are sure everything is OK, make a boot floppy for the new kernel as described earlier, then modify your bootloader configuration file to make the new kernel the default.
Now build the standalone PCMCIA support package as follows (you must now be running the new kernel):
Now test the new PCMCIA support; you should have a memory card with some data on it available for testing. First manually install the PCMCIA modules and restart PCMCIA services as follows:
If these commands worked, an lsmod command should show the three modules in the list. You should now be able to plug in a memory card and get two "happy" beeps. Another lsmod command should show that memory_cs and a couple of other memory related modules are now present; doing ls /dev/mem* should show several memory devices present, as follows:
/dev/mem /dev/mem0a /dev/mem0a0c /dev/mem0c /dev/mem0c0b /dev/mem0c0c
Copy the card contents to a file as follows:
cp /dev/mem0c0c test-file
then look at the file with:
od -t x1 -A x test-file | less
See Linux FLASH Card Reading for more info.
The final steps to reconfiguring your notebook PC to use standalone PCMCIA support require modifying a couple of system files. Keep old copies to use if you want to go back to your old kernel for any reason.
Document any extra or special steps you took....NOW!!