Google Site SearchFN Site Search FN Blog Login FN Blog Login
Site Navigation:
 
 
 Fedora Core on Thinkpad X40 Customization HOWTO

Fedora Core on Thinkpad X40 Customization HOWTO

by Eric S Raymond on Aug 04, 2004 (UPDATED 2004-08-06)

Revision History
Revision 1.12004-08-06esr
Solution to the Suspend problem.
Revision 1.02004-08-05esr
Initial release. Workaround for screen garbage, setup steps for the Atheros, some discoveries about ACPI.

Abstract

This is a HOWTO on configuring and customizing Fedora Core 2 for use on an IBM X40. If you are viewing it anywhere but on its home site, you may wish to go there for the most recent version.


Things That Don't Work, And How To Fix Them

Out of the box, several features of the X40 don't quite work right under Fedora Core 2. I noticed these problems:

Garbage on the display when you close and open the lid.

A band of garbage appears at the top of the display when you close and open the lid. Keith Packard tells me this probably means the BIOS is restoring the video start address incorrectly.

The workaround is simple; Ctrl-Alt-F1 followed by Ctrl-Alt-F7 to switch to a text display and back. But the real remedy is to back down to APM (see below). This problem only manifests under ACPI.

Fn-F4 to suspend doesn't work.

The underlying problem is that stock FC2 enables ACPI support, which is not yet quite ready for prime time. Backing down to APM works around this problem.

To accomplish this, do the following steps:

  1. Add acpi=off as a kernel boot parameter. The easiest way to do this is by editing /etc/grub.conf. Doing this seems to stop acpid(8) from starting up at boot time.

  2. Make sure apmd starts at boot time by running chkconfig --levels 35 apmd on. If you neglect this step, the apm(1) client will misleadingly claim that the kernel doesn't have APM support.

Note that this is suspend-to-RAM, like ACPI state S3. Software suspend to disk (ACPI state S4, like the Windows hibernation feature) is a trickier problem. There are no fewer than three implementations of this (see Software Suspend For Linux for a comparison). The default swsusp feature in 2.6 does not yet work on the X40.

The on-board wireless hardware is not supported out of the box.

There are three different NICs inside X40s — the Intel Wireless Pro 2100 (g only), Intel Wireless Pro 2200 (bg), or the Atheros (abg), You can tell which you have by looking at the output of lspci(1). Below I give a recipe for enabling the Atheros 802.11abg card.

I have the Atheros 802.11abg NIC. It's supported by the MADWIFI project. Here are the steps I took to get it working:

  1. I couldn't find any prebuilt RPMS for FC2, so I downloaded the HEAD code from CVS as described here and followed the instructions in the README. I also applied this patch, which is supposed to improve the behavior of the WiFi LED (alas, it did not). Even if you do find FC2 RPMs, you may want to build from source to give the WiFi LED any chance of working (see below).

  2. The X40 does have a wireless-on LED (the leftmost one in the strip below the screen, next to the Bluetooth rune), though I have not yet seen it light up. Some future version of the Madwifi driver may fix this; to give it a chance, you will want the following environment setting active during compilation:

    export COPTS="$COPTS -DSOFTLED"
    
  3. Type make to build the modules.

  4. Go root and type make install to install the result modules where they will be loaded automatically.

  5. Now reboot; the new modules should load at boot time, and if they do kudzu will ask you to configure the Atheros card. Tell it to use DHCP (you can change this decision later using the normal network configuration tools).

  6. Once you have rebooted, running lsmod should show that all three modules are loaded — something like this:

    ath_pci                33688  0 
    wlan                   49704  2 ath_pci
    ath_hal               124624  2 ath_pci
    
  7. Type ifconfig -a. You should see an entry for “ath0”. This is your wireless device.

  8. Type ifconfig ath0 up to enable the device. Later, you can use the normal network configuration tools to set it to be enabled at boot time.

  9. Type iwlist ath0 scan. If you get at least one cell listing, you are golden — your card has detected an active wireless access point.

  10. To connect your card to one of the access points, you will need to issue a command something like this:

    iwconfig ath0 mode managed essid XXXXX
    

    where XXXXX is one of the ESSIDs that showed up in your scan.

  11. I tripped over some strange bugs or misconfigurations when trying to get dhclient(1) to grab a DHCP address off my wireless router. Eventually I gave up and just did this:

    #!/bin/sh
    ifconfig eth0 down
    modprobe ath_pci
    ifconfig ath0 up
    iwconfig ath0 mode managed essid belkin54g
    ifconfig ath0 192.168.1.13
    route add default gw 192.168.1.1
    

You may find that ath0 does not reliably come up at boot time, failing with a message about the ath_pci device not being there yet and deferring initialization. If so, you'll either have to do ifconfig ath0 up moanually or put it in /etc/rc.

Things That Do Work

Binding ThinkPad Buttons with tpb

A program called tpb (for ThinkPad Buttons) allows you to bind Thinkpad special keys to programs. It installs and works fine on the X40. You may have either to configure it without xosd or build xosd from source; I found that some strange bug in the packaging of tpb makes it believe the xosd library is out of date even when it is not (this is in tpb 0.6.2, it could be fixed in later versions).

Running tpb -v shows that tpb is able to see the “Access IBM” key being pressed, and believes it to be the “ThinkPad” key that you bind with the --thinkpad= option.

tpctl works, other than SMAPI functions.

There is an open-source tool especially for tweaking Thinkpad settings. It's called tpctl, and consists of a kernel module and two front ends. There is even a GUI front end for this program.

I was able to build and install the thinkpad.ko kernel module without difficulty by following the directions in the package README of version 4.14. However, I was not able to get the module to autoload, though I could load it manually with modprobe. Also, most tpctl requests I tried then returned an error message like this:

SMAPI BIOS error 086 ("function  not supported") -- exiting

There are a few useful exceptions. The --info-CMOS-RAM, --info-display, --info-processor, --info-UltraBay, and --info-docking options appear to return valid data. So do --info-pm and --setup-all.

But all the probes that depend on querying the SMAPI BIOS fail. I don't know whether the X40 simply lacks one or the driver can't see it. It may be that the SMAPI BIOS isn't there at all, having been replaced by ACPI. The main thing you'd normally want to do with it (suspend/resume) is supported by APM.

Things that Will Work Someday

ACPI

ACPI is partly working. Hitting the power-off button while Linux is at runlevel 3 or 5 dispatches through acpid(8) and runs shutdown -h now as it should.

Suspend/resume doesn't yet work ynder ACPI, though. By running acpi_listen(8). I was able to determine that Linux's ACPI support does see an event when the F4 button is pressed. Here is what the even notification looks like:

button/sleep SLPB 00000080 00000001

The last field is a sequence number that will increment each time. None of the other special keys seem to generate a visible event. Lid opens and closes both generate an event that looks like this:

button/lid LID 00000080 00000001

I wrote the the following script as an attempt to do a software suspend to RAM under ACPI:


rmmod uhci_hcd ehci_hcd
echo 3 >/proc/acpi/sleep && hwclock ——hctosys
echo "Resuming processes...."
modprobe ehci_hcd
modprobe uhci_hcd

Unloading the USB modules is necessary, otherwise the attempt to sleep the machine will fail because the USB driver won't suspend. With the unload, the suspend apparently succeeds (the crescent-moon suspend light on the X40 goes on) but I can't figure out how to wake the machine up afterwards. Opening the lid doesn't do it. I'm told that pressing the power button is supposed to, but I have not found this reliable.

I've heard a report that the 2.6.8rc3 kernel has much better ACPI support. Paul Ionescu says “I use kernel 2.6.8-rc3 with latest acpica patch from 17-july-2004. Prior to this patch, I had a lot of problems with restoring interrupts after suspend. And with this patch, you can resume by opening the lid or pressing the Fn button for a couple of secs.

He continues: “For some models of thinkpads I have to add acpi_sleep=s3_bios kernel parameter in order to get proper video resume from S3. In this new kernel I only have to remove ehci-hcd to make it suspend, and I don't really need to change to textmode. An echo 3 > /proc/acpi/sleep is enough for me (T41/R50p).

I plan to try this when 2.6.8-final comes out. For now, APM is good enough

Helpful Links

Internally, the X40 is much like a T40. This page helped get me started.

There is a good general FAQ covering Linux wireless support here.

There is an X40 HOWTO for Debian users here. It includes information on making the X40 modem, IrDA, and Bluetooth hardware work.

This Fedora Core 1 on X40 installation note warns that trying to use the Windows 2200BG driver through the linuxant wrapper doesn't work under FC2.