My sister needed me to pull some pictures off her digital camera so we could place an ad in our parents home paper for their 50th wedding anniversary. Unfortunately, she didn’t have the USB cable for the camera. However, the camera had an SD card. And my Acer Aspire 1691WLMi has an SD slot. The question was: would it work?
I’m still running Fedora Core 5 on the laptop. It’s time to upgrade, but I haven’t had time. It’s on the todo list, of course (isn’t everything?). The current kernel for FC5 is 2.6.20. This works fine for most of my hardware (still haven’t tried the Firewire or Bluetooth support) , but it doesn’t seem to support the SD slot. So I did some googling and found, buried in a Ubuntu forum (I think), a note that support for my hardware was much improved in 2.6.22. The short answer is: yes, this kernel lets the SD card slot work. But the process is not point and click. Still, I’m sure others will want to know how to do it. So here it is.
First, you have to check that you’ve got the same hardware I have. Run the command
lspci -v
to list the hardware on the PCI bus. This should include the Texas Instruments PCIxx21 Integrated FlashMedia Controller, which is the controller that handles the SD slot. The output from this command should include something like this:
06:01.3 Mass storage controller: Texas Instruments PCIxx21 Integrated
FlashMedia Controller
Subsystem: Acer Incorporated [ALI] Unknown device 0066
Flags: bus master, medium devsel, latency 57, IRQ 18
Memory at b0114000 (32-bit, non-prefetchable) [size=8K]
Capabilities: <access denied>
If this is the hardware you have, then you can follow this process to get access to an SD card. First, download the source for the 2.6.22 kernel from kernel.org. Unpack the source and change into the source directory:
tar xvjf linux-2.6.22.1.tar.bz2
cd linux-2.6.22.1
Note that the kernel number may have changed by the time you read this. Next, you need to build the source into an RPM you can install. This isn’t as hard as it might seem. Start by preparing the source tree and making sure the kernel
make mrproper
Edit Makefile to set EXTRAVERSION=SDCARD
The SDCARD setting will give your new kernel a special name so you can easily identify it. Next, copy the config file from your current kernel into the source directory. The config file can be found under /boot and is named config-<kernel name>, where kernel name can be found using the command uname -r:
cp /boot/`uname -r` .config
Now, use this configuration to configure the kernel source. This next command will prompt you for a bunch of things. You can safely take the defaults (just hit ENTER each time) though, as I discovered, the kernel you create might not support all your hardware the way your current kernel does. The result is that I have a special kernel I boot into to use the SD card (a minor nuissance until I upgrade to FC7):
make oldconfig
Now you can compile the kernel, the loadable modules and create an RPM package that you can install:
make bzImage
make modules
sudo make rpm
You must run this last command as the root user unless you’ve set up your current user id’s directories for use with building RPMs. The kernel will end up in /usr/src/redhat/RPMS/i386/. You now need to install this kernel:
rpm -ivh kernel-2.6.22.1SDCARD-2.rpm
You should also save a copy of this rpm to a local directory. Copy the source RPM along with this binary RPM too.
With the kernel installed, we need to do a little configuration before booting it. First, get the kernel image name from /boot:
ls -l /boot/*SDCARD
-rw-r–r– 1 root root 76494 Jul 28 18:09 /boot/config-2.6.22.1-SDCARD
-rw-r–r– 1 root root 944417 Jul 28 18:09 /boot/System.map-2.6.22.1-SDCARD
-rw-r–r– 1 root root 1793012 Jul 28 18:09 /boot/vmlinuz-2.6.22.1-SDCARD
The kernel image name is 2.6.22.1-SDCARD. We need this to build an initrd image:
sudo mkinitrd /boot/initrd-2.6.22.1-SDCARD.img 2.6.22.1-SDCARD
The initrd image is automatically installed into the /boot directory, where it needs to be. You should save a copy of this file in the same plce you saved your RPM files.
Next, update GRUB to be able to boot the kernel. Add an entry like the following one to the end of your /etc/grub.conf file (you need to do this as root):
title Fedora Core SDCARD (2.6.22.1SDCARD-2.fc5)
root (hd0,1)
kernel /boot/vmlinuz-2.6.22.1-SDCARD ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.22.1-SDCARD.img
Now you’re ready to reboot to use the new kernel. Be sure to hit a key when grub prompts you at the start of the boot so you can select the new kernel. Once the kernel has booted and your logged back in you’ll need to load some modules manually (these probably are not loaded automatically for you, but use lsmod to verify):
modprobe tifm_sd
modprobe mmc_core
modprobe sdhci
modprobe mmc_block
You should load them in this order, too. You’ll need to do this as the root user. You can download an init script to automatically this for you, though it needs some tweaking to be run as an init script. Copy this to /etc/rc.c/init.d/sdhci.
After loading modules you can insert the SD card into the slot on the laptop. You can verify that the card is available by checking the output from dmesg:
dmesg | grep mmc
You should see some messages about /dev/mmcblk0 and /dev/mmcblk0p1. These are the devices you need to mount. The device names might be slightly different but should be prefixed (I believe) with mmc. To see what partitions are on the card you can use fdisk on the device without the “p” suffix:
fdisk /dev/mmcblk0
I did this to see that the partition was a FAT16, so I mounted the partition like this:
sudo mount -t vfat /dev/mmcblk0p1 /mnt
Now you can view the SD’s contents.
Caveats
This all works, but the config didn’t pick up some of the hardware config stuff, like my wireless doesn’t work anymore. I don’t know why exactly. Until the Fedora project (or one of the repositories) makes this kernel available for FC5, you’re stuck doing the process manually and may be stuck booting into a special kernel (like I am) just to access the SD card slot.
Of course, once I upgrade to FC7, this isn’t likely to be an issue.