[ Think Pad R40 ][ Previous | Next ]
Linux - Fedora Core 2
SInce I needed to port some drivers from 2.4 to 2.6, it was time to update the laptop to a 2.6 kernel. Rather than try to incrementally update a myriad of tools and modules, it seemed to make sense to just dump RedHat 9 and move to a 2.6-based distro.
A lot of the following text is the same as in the RedHat 9 page. I have left it here, rather than referring to it, to try to make this page "stand-alone".
Downloaded the Fedora Core 2 DVD iso from the Fedora Project . Burned using Nero in win2k.
Note: I do my DVD burning on my P4 deskside. It is organized somewhat like the laptop: win98, win2k, solaris, RH6.2, RH7.2, RH9 (several copies - different kernels), FC2. There are also several "scratch" FAT32 partitions available to all OSs. I found out the hard way what I should have already known: regardless of the partition's size, a FAT32 fs limits file size to 4G - not enough for a DVD image. Depending on the download manager used, the download may seem to run to completion, but the whole file isn't there.
I converted one of my "scratch" partitions to NTFS and downloaded the image there. Probably should have done the whole deal on the Linux side, but there just wasn't enough space in those partitions.
Didn't fiddle the BIOS at all prior to install. Left acpi, plug-and-play and everything else in its default configuration.
Warning: I have used and recommended System Commander for years. However, I cannot recommend their SC8 version. Upgrading to it on my R40 garbled the HD sufficiently that Win2K would no longer boot. After discussing it with their support people, I tried a fresh install rather than an update. That too damaged the HD. In the end, I went back to SC7 and had to do a total Win2k re-installation. On top of that, support was very slow to respond, and so far they have refused to refund the purchase price because I took too long to ask - since I was waiting for their support to reply! Very sad.
Since Solaris uses the same ID as Linux swap (82) I ran win98>scin to change the ID to 99 to hide it from the Linux install. Otherwise, the Linux install might/would format the Solaris partition as swap space. I left the original RedHat Linux boot (100M), root (~6G), and swap (512M) partitions in place to be reformatted by the Fedora installation. After the Linux install, I changed the Solaris ID back to 82. Here are the partition tables as reported by (DOS) scout and Linux fdisk.
See warning below.
See KNOPPIX in the RedHat 9 page above for another approach to partitioning.
Warning: the initial RedHat 8.0 install modified the C,H,S values in the partition tables. I was able to manually repair using the saved scout.txt file, but win2k had been terminally damaged. I have no idea why this happened, or if it is likely to happen to anyone else. The fresh RedHat 9 install also diddled the C,H,S values. I don't know if this would have tweaked win2k again, but I made sure to repair the partition tables (by booting to DOS and running SCIN) before trying to boot into win2k.
The Fedora installation made an even bigger mess of the partition tables, which I was again able to manually repair. There has finally been some notice of this taken by others. A Fedorazine.com article titled "Dual Booting Issues With Fedora Core 2 and Windows: Prevention & Recovery " seems to address this issue. You can find a pdf at the link below or Google for it. I HAVE NOT TESTED THIS PROCEDURE AND HAVE NO IDEA IF IT REALLY WORKS!!!
Update 2005.01.19: I may have finally figured out why the corrupted CHS values can break win2k permanently. See partitioning notes.
Since SC7 is my overall boot manager, I had the RH install put the Grub bootloader in the Linux /boot partition, not in the HD's MBR.
New Kernel Build
The Fedora Core 2 stock kernel (2.6.6-1.435.2.3) comes with 4k stacks enabled. I planned to use the ndiswrapper wifi driver wrapper, and I knew it wouldn't run with 4k stacks, so I had to rebuild the kernel. I started with the (then) latest one: kernel 220.127.116.11 from www.kernel.org .
I used the 2.6.6-1.435.2.3 Fedora kernel's configuration as a starting place using the following procedure:
NOTE: since I hadn't previously rebuilt the stock kernel, there wasn't an existing .config file. "make oldconfig" picks up a Fedora default config - which doesn't seem to match the stock kernel. In particular, kernel debugging is enabled ( CONFIG_DEBUG_KERNEL=y ) which leads to HUGE modules. At the make xconfig step below I disabled kernel debugging, disabled 4k stacks, enabled the ext3 driver in the kernel (or it can't boot my ext3 root), enabled cpufreq to use the newer sysfs interface, made sure the Centrino cpufreq driver was eanbled, and enabled wifi support. I also disabled many drivers and modules that I didn't need. Here's the final .config.
tar -xjf <path to linux-18.104.22.168.tar.bz2>
cp .config ../linux-22.214.171.124
make xconfig and did some config editing
"make install" attempts to copy the appropriate stuff to /boot, and update grub.conf. It worked fine for me - YMMV.
Since I wanted to be able to mount the win98se, win2k, and "scratch" FAT32 partitions, I modified /etc/fstab to make that easier. Also added entries to allow quick mount of usb floppy and usb jump drive. It now looks like this: fstab. I automount the scratch logical partition, which gets shared by all the OSs, and leave the winxx partitions and usb stuff unmounted unless I need them.
For general information purposes, here are the dmesg boot log (from an apm boot), grub.conf, and modprobe.conf. Hard drive default configuration as reported by hdparm: hdparm report.
The stock radeon driver deliverd with Fedora Core 2 (Xorg X11 Release 6.7) works just fine on the R40. It seems to return from suspend/hibernate/blank without problems - at least when running in APM mode. In ACPI mode, none of those Function buttons work so I don't know if the underlying features work. Here's the (untouched) /etc/X11/xorg.conf .
I borrowed the TrueType fonts from my win2k installation:
# cd /usr/share/fonts
# mkdir truetype
# cd truetype
# cp /mnt/win2k/winnt/fonts/*.ttf .
# chkfontpath -a /usr/share/fonts/truetype
UltraNav TrackPoint and touch pad both work (at same time). Usb mouse works. Usb mouse scoll wheel works. If X is running the first time the usb mouse is plugged in, it isn't immediately recognized. Unplug it and plug it in again. After that it will be recognized. UltraNav and usb mouse will work at the same time.
Bult in Intel Pro100 VE NIC works. Here is my /etc/sysconfig/network-scripts/ifcfg-eth0.
I had intended to use ndiswrapper again, but Intel finally got the ipw2100 project started so I used that instead. It is still a work in progress. I was able to get version 0.55 working by applying a couple of patches provided on the mailing list by an Intel engineer. There have been several versions released since then, and it looks like it is going to turn into a capable piece of software. I have only tested it in fairly simple modes: non-broadcast essid, no encryption, fixed IP address, and DHCP.
My /etc/sysconfig/network-scripts/ifcfg-eth1 was built according the the ipw2100 INSTALL document and uses any available essid, and DHCP. To specify an essid, replace the "any" with the specific essid desired. You can buld multiple ifcfg-xxxx scripts to support different wifi environments. I have ifcfg-eth1 and ifcfg-eht1.home. Both specify DEVICE=eth1. You can ifup and ifdown them manually, but I use a little gui script. See Network Management below.
The Fedora network startup script loads all drivers for all interfaces in /etc/sysconfig/network-scripts (all those with an ifcfg-xxx file) even if those interfaces are not enabled at boot time with an ONBOOT=yes entry. This is (apparently) to preserve the order in which interfaces and drivers are associated. This has the side effect of turning on my radio - even though eth1 is not "up". My normal situation is wired via eth0.
In the interest of battery life, I put a line in rc.local to just unload the driver at the end of the boot sequence.
The smartlink-2.9.9 driver and modem daemon worked "out of the box". You should be able to find the latest version at www.smlink.com . I put together an init script for the modem driver and daemon based on the Debian example. Put slmodemd in /etc/init.d if you want to treat the modem as a service. I ended up using my "oneup" script below to do this on the fly.
The provided system-config-network-1.3.17 gui thing works OK for controlling the network devices, I suppose, but it has a few quirks. If you build a device configuration and later delete it, the ifcfg-xxxx file (and others) persist. Also, I couldn't get automatic loading of the wifi and modem driver to work when one of those device types was activated.
I wrote a little script - oneup - that does an ifdown for any "up" device, unloads any networking drivers, then does a driver (and daemon, if necessary) load, then ifup of the chosen device. If the device type is wireless, it loads the ipw2100 driver. If the type is modem, it loads the modem driver and starts the modem daemon. Doing the ifdown thing first allows the ifup to also set the default route.
As self-abuse, I tried to make it a gui applet by using zenity to pop up windows as required. oneup presents a menu of available devices (including "stopall") and does the appropriate thing when one is selected. I find it quite useful, but it isn't really complete. It doesn't allow creating the devices - do that by hand or using system-config-network. It also probably doesn't handle all error cases correctly, and hitting the "cancel" button while it is doing something may make a mess.
I made it a Gnome panel applet that authenticates with pam.
If /etc/wvdial.conf and /usr/sysconfig/network-scripts/ifcfg-worldnetBI are configured correctly, selecting a modem device will do the dialing and login. These two example scripts are mine with the private stuff obscured.
Not really tested. After /sbin/modprobe ohci1394, and plugging in a Sony camcorder, I see this in dmesg:
ieee1394: Node added:....
So it looks like the camera plug in event is at least being recognized. However, the second time I did modprobe and rmmod, the rmmod hung. The rest of the system seemed OK, but I couldn't break out of the rmmod. When I tried to shut down, it hung on "Stopping PCMCIA servcies..." Had to use the power button to shut down.
Tested with Lexar JumpDrive and SanDisk Cruzer Micro:
#mount /dev/sda1 /mnt/usbjump
With modified /etc/fstab, just
Gnome CD creator doesn't work. This worked at one time, so it may be kernel specific. I'm not going to worry about it since I can use cdrecord directly.
cdrecord (Cdrecord-Clone 2.01-dvd) works if the correct dev option is used. In RH9, the burner showed up as scsi device 0,0,0. With Fedora, it is 1,0,0. No matter, since running cdrecord with this type of dev= specification results in:
cdrecord: No such device or address. Cannot open '/dev/sg*'. Cannot open SCSI driver.
Looks like the ide-scsi stuff is b0rked. Fortunately, using dev=/dev/cdrom or dev=/dev/cdwriter works.
cdrecord defaults to "burn free" off (no buffer underrun protection). To use burn free, a cdrecord command looks like:
cdrecord dev=/dev/cdwriter speed=24 driveropts=burnfree <path to iso to be burned>
Note that cdrecord is fed an iso to be burned, not normal files or directories. Those must be processed into an iso first with something like:
mkisofs -J -R -l -o <name of iso to create> <path to files to be burned>
You can mount the created iso to check it prior to burning with:
mount <path to iso> -r -t iso9660 -o loop <your mount point>
This laptop is fast enough (and has a "burn free" burner) so you can pipeline the operations:
mkisofs -J -R -l -x ".*" <path to files to be burned> | cdrecord dev=/dev/cdwriter speed=24 driveropts=burnfree -
The -x ".*" omits "invisible" files. Don't forget the "-" at the end.
DVD, CD, and Video playing
The stock Gnome CD player works.
Tried the xine video player this time (v0.99.2). Basically, it works just fine. It took some fiddling to get any sound out of it, though. In order to get to the appropriate settings in xine, you first go to setup and set the experience level to "master of the known universe". Then I could set the video driver to xshm. I scrounged the rpms here: http://cambuca.ldhs.cetuc.puc-rio.br/xine/
The xine Mozilla plugin worked OK with mpegs, but I couldn't get it to play quicktime movies.
The FC2/126.96.36.199 combo supports both apm and acpi. I have two entries in grub.conf so I can boot in either mode. In acpi mode, none of the R40's Fn/Fx buttons do anything. I presume there is a way to make them work, but it was easiest to just run in apm mode where (nearly) everything works. Further, in APCI mode when the battery runs low, the laptop just crashes. Ouch. In APM mode it raises an audible alarm and does a standby to RAM. A BIOS config change would probably make it hibernate instead.
What works in APM mode:
Standby (LCD off) (Fn-F3 or apm -S) works.
LCD brightness up/down (Fn-HOME, Fn-END) works.
Monitor out select (Fn-F7) (probably) works.
Suspend to RAM (Fn-F4 or apm -s) works.
Suspend to disk (hibernate) (Fn-F12) works.
Low battery suspend to RAM works.
Timed LCD standby works.
Timed disk spindown and timed suspend/hibernate haven't been tested yet.
With the laptop mode stuff sorted out (below) they may work.
All the above works with the radeon driver - it no longer requires switching to VESA. Excellent.
I had previously created a hibernate file in the C: FAT32 partition (C:\save2dsk.bin, /dev/hda1/save2dsk.bin) with an IBM utility program since I had DOS/Winxx available (see Windows 98SE). If you don't, use fdisk to create a FAT32 partition, and use Andrew Tridgell's tphdisk utility to create the hybernation file.
tuxmobil.org has a Linux on Centrino Laptops page that addresses ACPI and other issues.
CPU Frequency scaling (speedstep) and Laptop Mode
Fedora Core 2 comes with the CPUFreq CPU clock scaling driver and drivers for several processor's frequency control mechanisms. It also comes with Carl Thompson's CPUSpeed user-space governor which controls the CPU clock frequency based on demand. CPUspeed works well, but there is some missing functionality and mis-configuration in the Fedora (RedHat) power management scripts. I managed to hack the scripts to get them to behave the way I thought they should, and went so far as modifying CPUSpeed as an exercise - not that it needed it.
If you are interested in the Fedora script modifications, or my CPUSpeed hack, read on. Bear in mind that this isn't my strong suit - but they seem to work for me. Sorry if this has already been done.
NOTE: The following discussion applies when running in APM mode. I was a little startled to discover that the scripts described here depend on the apmd daemon, which only runs in APM mode. When in ACPI mode, the acpid daemon runs instead. Unfortunately Fedora provides just a little two-line power button example acpid configuration script in /etc/apci/events, not a fully capable script. Here is a RedHat post that mentions the issue. I _did_ find a Gentoo-oriented script here, that may be of some use. Sure would be nice if there was a either a Fedora version, or a wrapper for apmscript and friends. If anyone has more current info, let me know. In the meantime, I'm sticking with APM.
NOTE to the NOTE: Documentation/laptop-mode.txt and Bart Samwel's Laptop Mode Tools deserve a good look. I haven't studied them yet. At a lower level, a little poking around with acpi_listen might be informative.
First, /etc/sysconfig/apm-scripts/apmscript is a little "buggy", 1) it uses the older /proc/cpufreq interface to the frequency control driver, but my kernel was built with the sysfs interface so apmscript couldn't do frequency control governor selection. 2) it checks ac-online status at a power change (ac unplugged/plugged in) but not at boot time, so the boot time mode is always ac-online regardless of actual status. This has been reported as a bug, but apparently no action has been taken: http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=91953
I modified the script to use the newer /sys/devices/system/cpu/cpu0/cpufreq access to cpufreq, and added the ability to pick up governor selections from the apmd configuration script. If the governors aren't specified, they default to the (sysfs style) "performance" for ac operation, and "powersave" for battery operation. The script also now probes the sysfs cpufreq interface - not /proc/cpufeq - to determine if frequency control is supported.
I also modified apmscript to do the same power source checking at "start" that it does at "change power". Here is the entire modified apmscript. Now it sets laptop mode, selects the "powersave" governor, and shuts down those services specified in /etc/sysconfig/apmd when running on battery power, and does it correctly (I think) at boot time too.
Related modifications were made to the apmd configuration script to allow defining the governors (for completeness - the defaults in apmscript are now OK) and a few services were added to the list of those to stop when on battery power. Your choices may vary. Heres the modified /etc/sysconfig/apmd . Note that I don't actually enable CPUFREQ in apmd, since I ended up using the cpuspeed and my cpuspeed2 user-space governors.
Unfortunately, it isn't quite that simple. Some of the services that can be specified in the apmd script for shutdown are started after apmd at boot time. That means it can't shut them down if booted under battery power since they will be started later in the boot process. The fix was to change the chkconfig parameters to load apmd as late as possible. Heres the (slightly) modified /etc/init.d/apmd .
The last thing (so far) is an apmcontinue script to do the things at boot, shutdown, and power change time that are not done in apmscript. This is where RedHat says my mods should have gone. All I do here is remount the root partition with the "noatime" option so the drive isn't constantly accessed. This lets the HD spin down during periods of inactivity. My simple /etc/sysconfig/apm-scripts/apmcontinue script is invoked whenever apmscript is called and gets passed the same arguments. You can add stuff here easily.
Here are patches against the original scripts: apmscript , apmd in init.d , apmd in sysconfig.
Modified apmscript and apmcontinue to set modes correctly at resume. Suspend on battery, resume on AC (pretty common scenario I would think) wasn't picking up the power mode (original and my version).
CPUSpeed (www.carlthompson.net/Software) is a userspace frequency governor that comes with FC2 and works fine out of the box. One minor gripe is that it doesn't detect AC on-line status when running APM - which is how I prefer to run my R40. I got to poking around in the code and decided to see if I could "improve" it. I'm not a programmer, just an old hardware guy, but it looked like a good place to learn something. In the end I came up with a version that works well for me.
The original cpuspeed provides the ability to control the CPU clock frequency based on demand. It calculates CPU idle percentage and adjusts the clock accordingly. It can also reduce the CPU clock frequency to minimum when running on batteries (ACPI only) and when the CPU temperature reaches a certail level (ACPI only). It works with both 2.4 and 2.6 series kernels.
I was able to add the following "features":
Dropped kernel 2.4 support
Detect AC on-line status and battery charge level (in APM too)
Automatic detection of correct /proc/acpi files for AC, battery, and thermal state
Separate "policies" for AC, battery, and low battery operation, i.e. MAX, DYNAMIC, MIN
NOTE: The earlier versions of cpuspeed2 would only detect single batteries. Multiple batteries would (probably) confuse the low battery calculation. The latest version (0.53) attempts to identify multiple batteries and include all in the capacity calculation. I don't have a way to test it properly on my ThinkPad.
Even if it works correctly, it involves a lot of computation for not much return: a separate policy for low battery operation in the multiple battery case (in ACPI mode). It probably makes more sense to use the earlier version and just disable the low battery detection if using multiple batteries, but that isn't my call. It was an interesting exercise. Let me know...
All this stuff can be overridden/configured by editing /etc/sysconfig/cpuspeed2. Please note that the default overtemperature threshold is just a W-A-G set at 75C. I have no clue what an appropriate value is, and anyway, this isn't guaranteed to keep your computer from frying. I don't think it will do you any harm if you try it., but after all, this was just an old man's homework assignment.
The approach to making the changes was to change the name from cpuspeed to cpuspeed2 and just hack away. If I had generated a patch, it would have been _almost_ as big as the original source since I meddled with almost everything. I am uncertain if I have gotten the Copyright, GPL, and attribution of the original author handled correctly. If not, I will change it immediately.
This exercise wasn't intended to be unleashed on the world, but if you care to try it, please let me know if it works for you. I can only test on my R40, so I don't know if it will behave on other platforms. For that matter, I don't have the coding chops to maintain it, and Carl's original is a perfectly fine piece of software. Anyway, for the foolhardy and/or curious, here it is: cpuspeed2
Works as tested with Netgear FA510 NIC.
No formal testing done beyond the simple hdparm stuff. Default IDE DMA mode seems to be udma5. Boots pretty quickly. Hdparm test results:
/sbin/hdparm -tT /dev/hda
highest clock speed (1300MHz)
Timing buffer-cache reads: 1536 MB in 2.00 seconds = 766.97 MB/sec
Timing buffered disk reads: 62 MB in 3.10 seconds = 20.02 MB/sec
lowest clock speed (600MHz)
Timing buffer-cache reads: 1420 MB in 2.00 seconds = 709.04 MB/sec
Timing buffered disk reads: 60 MB in 3.01 seconds = 19.90 MB/sec
The buffer-cache reads are approximately 10x those reported by RedHat 9. I doubt that the actual performance has changed.
I haven't timed it carefully, but just letting it sit on the desk and do its timed HD spindown and LCD blank and using it occasionally, it looks like a little over 4 hours. This this is with a tired battery that has lost about 10% of its capacity.
[ Think Pad R40 ][ Previous | Next ]