FreeBSD on IBM Thinkpad X40
Notes on setting up and running FreeBSD on IBM Thinkpad X40 notebook
These are the steps and settings in getting FreeBSD running on an IBM Thinkpad X40. This article deals with a non-dual boot setup, and installation using IBM's USB DVD-CDRW drive.
Current recommended version of FreeBSD is FreeBSD-6.0, and unless otherwise noted, the instructions are for this version.
Removing Windows
First thing to do was removing the Windows sticker. :) It can be difficult to remove. Slide a thin blade underneath the edge and lift it up slightly. This will allow you to remove the sticker quite easily. The Windows XP ID sticker underneath the laptop however is not quite so easily removed. I had quite a bit of paper and glue still left behind after getting most of it off. It can be rubbed off with a soft cloth, but still a bit is left over.
Don't remove Window just yet
Pressing any of the notebook function keys such as volume, screen, LED light etc. will hang FreeBSD after install if you don't disable the second IDE channel first.
Disabling second IDE channel
From reports [1] there is no functionality loss when disabling the second IDE channel. When using the docking station devices such as the ultrabay drives will work just fine.
Disabling from IBM Thinkpad Recovery tools
...
Disabling using a DOS boot disk and PS2.EXE utility
Instructions from FreeBSD Mailing list archives
Getting drivers from Windows XP
If your WLAN card is an Intel, you will still need Windows, to extract some drivers for use in FreeBSD (see Network - Wireless).
Somebody should tell IBM to also provide these drivers in ZIP format, instead of a Windows executable.
For Intel(R) PRO/Wireless 7100 LAN Card Driver, you will need to copy these two files. A USB key is handy for this.
- W70N501.INF
- W70N51.SYS
Removing Windows XP and Recovery Partition
Reports have indicated that installing FreeBSD even with the partition set as protected in BIOS settings, prevents the recovery programs from starting up.
Installation
Installating from USB DVD Combo Drive
There are no problems with installing FreeBSD 5.3 with a USB DVD-CDRW drive. Boot options may have to be changed and can be done by pressing F12 on bootup and selecting USB CDROM as the bootup device.
Supported Devices
Network - Ethernet
The Intel PRO Gigabit Ethernet adapter is detected and works without problems as em0 device.
em0: <Intel(R) PRO/1000 Network Connection, Version - 1.7.35> port
0x7000-0x703f mem 0xd0200000-0xd021ffff irq 6 at device 1.0 on pci2
Network - Wireless
Depending on the X40 model, it will either be an Atheros WiFi card (often reported as IBM WiFi card) or an Intel 2100 WiFi card reported as Intel(R) PRO/Wireless 7100 LAN Card Driver by pciconf. Both are supported.
Atheros
This card is supported natively by the ath driver. It can compiled into the kernel by adding the following options or loaded as a kernel module using kldload (untested)
device ath #Atheros
device ath_hal #Atheros HAL
device ath_rate_onoe # Onoe rate control for ath driver
Intel Pro/Wireless 7100
This wireless card is supported both by ndiswrapper (Windows driver) as well as native drivers. ! Native IPW and IWI drivers
There is good documentation available at the driver website.
It is supported natively on FreeBSD. Users however will need to download the firmware drivers from the ports under net/ipw-firmware and net/iwi-firmware respectively.
Users need to do an ifconfig ipw0 up or ifconfig iwi0 up after loading the firmware (port rc startup script) in order to turn the radio on.
Depending on your card, add either of the lines to your rc.conf to load the firmware on startup.
ipw_enable="YES"
iwi_enable="YES"
ndiswrapper (aka Project Evil)
This is confirmed to be working, there are some quirks such as sometimes not being able reset the interface once it's associated with a network. Generally it works quite well.
The procedure is well documented in the Wireless Networking section of the handbook. The follow are the steps specific to the Intel Pro/Wireless 7100 device.
- Copy the two Windows driver files mentioned before and copy them to /usr/src/sys/modules/if_ndis
- :
ndiscvt -O -i W70N501.INF -s W70N51.SYS -o ndis_driver_data.h - From this directory, run
makeand thenmake installThe ndis kernel modules are now installed. - To load the kernel modules,
kldload ndisand thenkldload if_ndisAdd the following lines in /boot/loader.conf to automatically load the WiFi drivers at startup
ndis_load="YES" if_ndis_load="YES"dmesgshould show the following informationndis0: <Intel(R) PRO/Wireless LAN 2100 3B Mini PCI Adapter> mem 0xd0220000-0xd0220fff irq 9 at device 2.0 on pci2 ndis0: NDIS API version: 5.1 ndis0: Ethernet address: 00:0c:f1:4f:93:9e ndis0: 11b rates: 11Mbps 2Mbps 1Mbps 5.5MbpsSee Working with Wireless section to get WiFi up and running.
USB
USB 1.0/2.0 is support and works fine with the devices I've tested it with.a Kingston USB Key, IBM DVD-CDRW drive, HP PSC 2110 printer and types of scroll mouse.
You will need to also add this line:
device ehci # USB 2.0
In your kernel config to enable it.
IR-DA
There are reports that this works with the comms/birda/ port.
It is detected as a serial device:
sio0: <Generic IRDA-compatible device> port 0x2f8-0x2ff irq 3 drq 3 flags 0x10 on acpi0
sio0: type 16550A
Display and Video Out
The display chipset is an Intel 855GM/GME Montara Integrated Graphics Device. There is no DRI support for i810/i930 support yet for FreeBSD. DRI support has been committed to the STABLE branch and will be available in FreeBSD 6.1. 2D graphics at 1024x768 and 24bit color is snappy, and video playback is smooth with xorg 6.8.1.
The screen does however have problems when you close and reopen the lid. You will get a garbled display at the top and the display is shifted a bit lower. This doesn't happen if restoring from S3 suspend. It also occurs when switching to external display.
When closing and opening a lid, a workaround in devd.conf was posted by James Snow
In /etc/devd.conf add the following lines at the bottom
notify 10 {
match "system" "ACPI";
match "subsystem" "Lid";
action "/usr/X11R6/bin/xrandr -display :0.0 -s 0";
};
One workaround is to start X from the console form external display.
Another workaround is use dua head xorg setup. (FIXME)
Xorg Display Device
xorg.conf Device settings
Section "Device"
Identifier "i810"
Driver "i810"
VideoRam 8192
#Option "NoAccel"
#Option "SWCursor"
Option "VBERestore" "yes"
Option "DevicePresence" "yes"
EndSection
Video Out
Pressing Fn+F7 will switch display output between LCD and external Monitor. See caveat regarding bug with X display above.
Xinerama/Dual Head
A few video output modes are supported.
- LCD Only
- LCD + Video Out (Clone mode)
This mode is currently buggy. Video out is not displayed properly.
- Video out only
- Dual Head
You can run dual head in two modes, xinerama and dual screen.
- Xinerama
With Xinerama enabled, your desktop will be the size of your LCD + Video out resolution.
- Dual Screen
In this mode, two separate desktops will be loaded as display 0.0 and display 0.1. You can access both, but windows cannot be dragged from one screen to another.
- Xinerama
... link to dual screen xorg.conf
Trackpoint and USB Mouse
Works immediately out of the box with FreeBSD's moused driver. An external USB mouse can be plugged in, and should work immediately and handled by FreeBSD's mouse driver in both console and X. Both trackpoint and USB mouse can be used interchangebly. If you have a USB wheel mouse the following settings will allow you to use the scroll wheel.
xorg.conf Input Device section
Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "Auto"
Option "Device" "/dev/sysmouse"
Option "Buttons" "5"
Option "ZAxisMapping" "4 5"
SD Card
Currently there is no support for SD cards. Some reference material has been release and a Linux driver is currently in progress.
ACPI and Power Management
Suspend and Resume
S3 suspend and resume works well add these lines to the respective configuration files. The settings below set the notebook to go into suspend when the lid is closed. Display, sound, mouse, usb devices and network devices all are restored upon resume.
/etc/sysctl.conf
hw.acpi.lid_switch_state=S3
hw.acpi.standby_state=S0
hw.acpi.suspend_state=S3
hw.acpi.sleep_button_state=S3
vfs.usermount=1
hw.acpi.sleep_delay=3
Mouse needs a device hint to work properly after resume.
/boot/device.hints
hint.psm.0.flags="0x2000"
CPUFreq (CPU Frequency Control Framework) and Speedstep.
CPUFreq has been merged and is available in FreeBSD 6.0. Other CPUFreq drivers such as enhanced speedstep for the X40's Pentium-M are also now part of FreeBSD.
This has meant that the performance controls have changed in rc.conf.
In my rc.conf I have this set:
performance_cx_lowest="HIGH" # Online CPU idle state
economy_cx_lowest="LOW" # Offline CPU idle state
powerd
FreeBSD now also has an adaptive power management utility called powerd that scales CPU according to usage.
In your rc.conf add these lines:
powerd_enable="YES"
Algorithms to improve life and performance are currently being worked on.
Depending on your usage, you can get up to 3hrs with standard battery and up to 6 and half hours with 8 cell battery.
Working with Wireless
Scanning for APs
Make sure the radio is on first and the firmware is loaded if using ipw or iwi drivers.
You can turn on the radio by running the following command (or iwi0 depending on your card)
ifconfig ipw0 up
Configuring dhclient
Using dhclient.conf options for DHCP enabled networks is the easiest way to get on to WiFi networks, multiple media options can be given for different networks.
In FreeBSD 6.0 this has now been replaced with OpenBSD's dhclient and media options no longer work in dhclient.conf. Instead users are supposed to use wpa_supplicant.conf for which no documentation has been written yet.
For now, you have to associate with an ssid after scanning manually and then run dhclient on the interface.
Scanning for AP
ifconfig ipw0 list scan
ifconfig ipw0 ssid 'access point ssid'
dhclient ipw0
Kernel optimizations and Compiler Flags
Compiler flags
The Pentium-M of the X40 is not really a Pentium III or Pentium 4, as well as having some unique characteristics that result in default i686 build flag of gcc resulting in less than optimum performance.[2]
cpuflags for the pentium-m has been added to FreeBSD 6.0 PR 72340
I have yet to encounter any problems however for ports with gcc 3.4.2 and -march=pentium-m optimizations for 6.0. You can enable pentium-m optimizations by added the following CPUTYPE. Keep the ? in front, some ports have problems compiling with CPUTYPE and need to allow the ports to override your CPUTYPE.
/etc/make.conf
CPUTYPE?=pentium-m
Kernel
The Pentium-M of the X40 has a large 1 MB L2 cache, which you can tune by adding a PQ_CACHESIZE in your kernel options.
Additionally removing I486_CPU and I586_CPU suppport may make some parts of the system run faster.
cpu I686_CPU
options PQ_CACHESIZE=1024
Screenshot



