четвъртък, 4 октомври 2007 г.

Lenovo C100 MMC/SD card reader in Ubuntu

The Lenovo C100 notebooks have built in MMC/SD/Memory stick card reader which doesn't work out of the box on Ubuntu Feisty. It needs just a little effort for enabling it. The card reader itself is produced by ENE Technology. Here is the output from lspci:

root@buhtum:~# lspci -nn
# ... truncated
01:04.0 CardBus bridge [0607]: ENE Technology Inc CB-712/4 Cardbus Controller [1524:1412] (rev 10)
01:04.1 FLASH memory [0501]: ENE Technology Inc ENE PCI Memory Stick Card Reader Controller [1524:0530] (rev 01)
01:04.2 Generic system peripheral [0805]: ENE Technology Inc ENE PCI Secure Digital Card Reader Controller [1524:0550] (rev 01)
01:04.4 FLASH memory [0501]: ENE Technology Inc Unknown device [1524:0551] (rev 01)

It turns that the sdchi driver supports the ENE chip, all you need to do is to add the PCI device IDs to the supported list of devices. The bug is described in Ubuntu database but it may some time to be included in the mainstream releases. Then you need to recompile sdhci module. Sounds scary but it isn't. Just follow these step:
  1. Get this patch and save it in your home directory.
  2. Prepare to build kernel:
    $ sudo apt-get update
    $ sudo apt-get install kernel-package libncurses5-dev fakeroot bzip2 linux-source
    $ sudo tar -xjvf /usr/src/linux-source-2.6.20.tar.bz2
    $ sudo cd linux-source-2.6.20
  3. Patch the kernel to support the reader:
    $ sudo patch -p1 < ~/linux-source-2.6.20_ene_cb712.patch
  4. Configure and build the kernel
    $ sudo make menuconfig
    <--- Exit, Save (As you propably don't want to change anything)
    $ sudo make-kpkg clean $ sudo fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers

    The last command takes about an hour to finish so be patient :)
  5. The new module is built in /usr/src/linux-source-2.6.20/drivers/mmc/host/sdhci.ko. Unload the original module and install this one to test it:
    $ sudo rmmod sdhci
    $ sudo insmod /usr/src/linux-source-2.6.20/drivers/mmc/host/sdhci.ko
  6. Plug a SD/MMC card in the reader - if everything is OK an window should pop up asking you to view the files in it:
  7. Replace the original driver with the new one:
    $ sudo dpkg-divert --divert /lib/modules/2.6.20-16-lowlatency/kernel/drivers/mmc/host/sdhci.ko.ORIGINAL --rename /lib/modules/2.6.20-16-lowlatency/kernel/drivers/mmc/host/sdhci.ko
    $ sudo cp /usr/src/linux-source-2.6.20/drivers/mmc/host/sdhci.ko /lib/modules/2.6.20-16-lowlatency/kernel/drivers/mmc/host/sdhci.ko
  8. Reboot and try again - it should work fine.

Няма коментари: