Cliff Hacks Things.

Friday, November 23, 2007

eeebuntu tip: using a custom kernel with ASUS's modules

I like the eee hardware but dislike the software. Personal preference; when I can't use a Mac I use Ubuntu. Readers will surely like some other distro (I know I used to be big on Gentoo), but this tip should not be distro-specific.

I wanted to put Ubuntu 7.10 on my eee without sacrificing any features. I've largely pulled it off, but it's a long journey down a narrow, undocumented road (sigh, Linux). The journey starts with the proverbial single step, which in this case is replacing the kernel with a largely identical one built from source. (If you're going to do anything cool to the kernel, you've got to be able to build it.)

I started out by installing Ubuntu 7.10 off a live stick. This isn't strictly necessary -- the kernel we're building will probably work in Xandros -- but since Ubuntu is my eventual goal, I aimed high. The live stick boots without a hitch (into Compiz, no less!) and the install was uneventful. Note before installing: there are files on the eee's filesystem you will need to complete this tutorial! It is worth your time to make a backup in an accessible form, such as dd'ing the filesystem to somewhere you can loop-mount it.

(Caveat lector: I actually installed onto an SD card, leaving the internal flash disk unmodified, but doing this requires a bunch of extra steps that are not documented here. It's sufficiently involved that I'll have to describe it in a followup.)

The install was largely uneventful and is not the topic of this post.

Ubuntu 7.10 does not, out of the box, support the following hardware on the eee:

  • The Atheros wireless card. (The madwifi drivers ASUS ships are not the 9.3.3 drivers, and a freshly built set from SVN trunk doesn't work either.)

  • The ASUS ACPI features for controlling backlight and powering PCIe devices on and off. The mechanism is conceptually similar to the kernel's asus_acpi module, but as I noted in a previous post, ASUS ships a modified driver.



(Those of you who have been in the Linux/FreeBSD laptop community for some time may notice how incredibly short that list is, and the fact that it does not include multihead 3D accelerated graphics, audio, and USB 2. How far we've come.)

As a result of the botched ACPI support, suspend/resume doesn't work quite right. Suspend-to-RAM will work sometimes, kinda, after a few VT switches to thunk the display adapter. Not good enough! I want instant suspend/resume and working wireless! Waaaah, the Mac has spoiled me! :-)

The pragmatic solution, if not the most FSF-friendly one, is to build a kernel with the exact version string from ASUS's so their binary modules will work. (If you care, note your kernel will be tainted! Danger Will Robinson!)

The recipe below skips some steps and is not intended for Linux or Unix newbies. Sorry; I've been immersed in Unix long enough that I'm not the right guy to write the newbie tutorial. Feel free to steal my instructions to make one!


  1. Prereq: a Linux machine with a working set of devtools and the 2.6 version of depmod. This might be the eee, I suppose, but I used a much faster machine. (Specifically, an Ubuntu 7.10 virtual machine under VMware Fusion.)

  2. Download the sources for the matching Linux kernel version -- in this case, 2.6.21.4. (For the kernel-impaired, it comes from kernel.org's 2.6 site.)

  3. Untar.

  4. Nab the ASUS kernel configuration, helpfully shipped right on your eee. It lives in /boot/config-2.6.21.4-eeepc. Copy it into your untarred kernel sources as a file named .config .

  5. If you tried to build the kernel now, you'd notice some errors about missing unionfs. Unionfs isn't in the 2.6.21.4 mainline kernel, but ASUS uses it. If you want it, download the version for 2.6.21.7 and apply it in the kernel tree with
    patch -p1 </path/to/patch
    If you don't want it, simply delete or comment out all lines in the config containing the word UNIONFS.

  6. ASUS's config in place, build a replacement kernel by issuing
    make oldconfig && make

  7. Create a directory to hold your new kernel and modules, and issue
    make INSTALL_PATH=/your/directory install
    make INSTALL_MOD_PATH=/your/directory modules_install
    You do not need to (and should not!) run these commands as root.

  8. In your directory are a bunch of files: a kernel and associated files at the root, and a lib/modules/2.6.21.4-eeepc directory with your modules in it.

  9. Copy the files out of the directory into /boot on your eeepc. Note at this point that, if you are still running Xandros, you have just overwritten your kernel. Hope you had a backup. (If you're running Ubuntu 7.10 you have installed an additional kernel alongside the main one. This is safe.)

  10. Copy the contents of the /lib... directory, not into /boot with the others, but into /lib/modules/2.6.21.4-eeepc.

  11. Try booting your eee. You will need to get to the grub menu and change the "kernel=" parameter. (How to do this is beyond the scope of this article.) If it does not work, I'm afraid I am not the man to help you; I make Linux work through sheer dumb luck and a lot of Unix engineering experience, but a Linux guru I'm not.

  12. If it seems to work, simply copy the atheros and acpi. directories from /lib/modules/2.6.21.4-eeepc on your eee backup filesystem into the same locations on the new one, and run (as root) depmod -a.



At this point, if it worked, you have a booting Ubuntu (or ${YOUR_DISTRO}) system running on a reasonable facsimile of ASUS's 2.6.21.4 kernel. If you issue modprobe asus_acpi or modprobe ath_pci, the modules should load (and put some control files in /proc/acpi/asus, or create wlan0, respectively).

You may find that suspend/resume to RAM works with the asus_acpi module loaded. Edit your /etc/modules as you see fit.

Getting from "loading the Atheros modules" to "reading Slashdot" is unfortunately involved -- but the process is no different than the normal madwifi drivers. (Hint: until I post my scripts, search on Google for "wlanconfig ath0 create".)

Happy hacking!

Labels: ,

19 Comments:

Post a Comment

<< Home