iBook Linux

This is my second full installation of Debian, first time as December 2001. After using and hacking around in Debian for ages, things started to act weird for no obvious reason. Some of the problems might come from the various dist-upgrades I've done, i.e from Woody, to Sarge and then after a while to Sid. Anyway, I'm going to write down a few tricks here till the next time I need to do a serious reinstall.

iBook (dual usb, IceBook, iBook2, PowerMac4,1) specifications:

Here's some device outputs; cpuinfo, lspci

Installation

Follow the instructions on this page and the links provided at the bottom of this page.

After installing the base system, change the stable entries in /etc/apt/source.list with sarge. Upgrade to Sarge using apt-get dist-upgrade.

Here's a list of some packages I usually put on a new Debian client install: file-rc, hdparm, iptraf, wget, lynx, bzip2, dnsutils, postfix (instead of exim), ntpdate.

And remove these: pcmcia-cs, tasksel, amiga-fdisk, setserial.

Power Management

I initially used pmud for power management, but later changed to pbbuttonsd since it's cleaner and easier to configure. And there's a nice GUI client to make it all even easier, powerprefs.

Kernel

Get the latest from kernel.org and copy default config from arch/ppc/ppc_defconf. Install libncurses5-dev and run make menuconfig to bake the kernel the way you want it. Tips: read the help pages. (Should add the list of required entries for iBook2.2 here sometime.)

Get the standard pack of compilers and builders; gcc, make and build-essential.

Install kernel-package and make the kernel deb by executing make-pkg kernel_image within the kernel directory. When upgrading to a new kernel, do a make oldconfig to find any new undefined parameters. Before recompiling the kernel do a make-kpg clean.

To get the modules part of the kernel running you need to install the module-init-tools package.

Partitions - fstab

Add the Mac OS X and Mac OS Classic partitions to fstab so they mount automatically. They're read/write compatible.

/dev/hda12 /mnt/macosx hfsplus defaults 0 1
/dev/hda14 /mnt/macosclassic hfsplus defaults 0 1

Also, to narrow down the hard drive usage, add noatime to the ext3 partitions to cut the last access file bit whenever a file is opened or accessed.

/dev/hda11 / ext3 errors=remount-rw,noatime 0 1

Network

Wireless

Add airport to /etc/modules for auto load and install the wireless-tools package.

Install ifscheme if you want different settings depending on your location. In /etc/network/interfaces put this:

map eth1
script /sbin/ifscheme-mapping

iface eth1-wifi-home inet dhcp
wireless_essid MyNetwork
wireless_key1 s:13character128bitkey
wireless_defaultkey 1
wireless_keymode open

iface eth1-wifi-any inet dhcp

Then you only executer ifscheme -s wifi-home when you're home and ifscheme -s wifi-any after you've configured the wireless network manually with iwconfig. If you encounter problems use ifdown eth1 and ifup eth1 to make things work again.

Also, lower the timeout when there's no dhcp server present by editing the /etc/dhcp3-client/dhclient.conf file and put timeout 5;at the end.

Ethernet

There's not much to say about the ethernet driver other than it's been stable for me all time I've used the ethernet interface. I've compiled the Sun GEM driver into the kernel.

Xfree86 with DRI - Desktop

DRI is a hardware accelerated rendering interface, thus freeing up the cpu.

Prequesite

There's no need for Michael Daenzer's external DRI modules anymore (xserver-xfree86-dri-trunk xlibmesa-gl1-dri-trunk), just use the official deb packages instead (xlibmesa-dri xlibmesa-gl xlibmesa-glu, see below).

Kernel

When compiling the kernel you can either build agpgart, uninorth-agp and r128 (or your card) inside the kernel or as modules. If you chose modules you need to add them to /etc/modules so that they load on boot (in the above order). Use lsmod to see if their're loaded.

XFree86 Installation

Install the basic X-Window system by executing apt-get install x-window-system. This will install a basic window manager and you're free to install whatever window manager you want later, i.e with xfce4, kde or gnome.

Configuration

The automated XFree86 configurator works great, you might need to change the driver and some minor settings like the identifiers to card0, screen0, monitor0, etc, make sure UseFBDev is enabled in the card0 section, maybe remove the PS/2 mouse section so that there's only one mouse section, fix the hsync/vsync and create a modeline with fbset -x. For everything else just check other peoples configs, see links below.

DRI Acceleration

You can test if DRI is enabled by checking glxinfo, it should report "Direct rendering: Yes". Another test is to run glxgears in X, i.e startx, open an xterm and executer glxgears. It should already be installed, it's included in xbase-clients package. With DRI I get around 500 fps and without around 70 fps (glxgears resulution is 300 x 300 pixels).

If you've successfully compiled the kernel and installed XFree86 but still don't get DRI you should try to lower the color depth to 16-bit. From the debian-ppc mailinglist:

If you don't have enough RAM in your video card, then you might try using a lower bit-depth for using DRI (say, like 16 bits per pixel), since enabling DRI would also enable DMA for the video (if I recall correctly), which would possibly offload a bit more of the tasks from the processor.

Tips and Tricks

Something else thats important is to set the best dpi for font bitmaps in /etc/X11/xinit/xserverrc. The default values are 75 and 100 dpi, try and see what works good for you.

To switch to the console after a X session is started, press Alt+Ctrl+Fn+F2 (or whatever console you want). To come back to the X session again try console F7 or F8.

To start applications in X from the console just export the display first, export DISPLAY=:0, and start the application. Must be the same user as the X session.

Buttons

To enable and configure all the quick buttons (brightness, audio and eject) you need to install the pbbuttonsd package.

For whatever reason, I don't have a /dev/cdrom device. I have to manually set the eject CD-ROM device to /dev/hdb in /etc/pbbuttonsd.conf to make the eject button work properly.

There's also a useful GUI, gtkpbbuttons, it shows window animations whenever you press one of the buttons. And if you add the "-t MacOSX" argument you get something that looks like it's OS X counterpart. Note: you have to manually start it or put it in you boot script (i.e gtkpbbuttons &) since it lacks a proper init script.

Sound

Enable ALSA in ther kernel as modules and install the alsa-base package. You can make sure the mixer settings is saved across reboots by doing a reconfigure of alsa-base, dpkg-reconfigure alsa-base.

I've read that ALSA sound only works when compiled as module, so put snd-powermac in /etc/modules to load it on boot.

You can check if the sound works by pressing backspace either in the console or opening an xterm in X. It should beep and you can adjust the sound level if you have the ppbuttonsd package installed.

If the application you're using (i.e xmms) depends on /dev/dsp, /dev/mixer and /dev/audio, you need to allow access to those devices by adding yourself to the audio group, execute adduser <USER> audio as root. Log off and on to commit the changes.

Fan Control

This iBook version doesn't support fan control, only iBook v2.2 and above does (link below).

CPU Scaling

To save some battery juice when the cpu is not in use or keep the iBook cool, install cpufreqd. The default config is reasonable good to scale the cpu in the various situations. Make sure cpu frequency scaling is enabled in the kernel.

You can get some useful information from the /proc/pmu/info and /proc/cpuinfo files. To find out the max and min cpu frequencies check the files in /sys/devices/system/cpu/cpu0/cpufreq/.

Trackpad

Configure the trackpad with the trackpad binary included in the powerpc-utils package. You might want to disable the click-when-tap behaviour by executing trackpad notap. To make this default, edit the /etc/pbbuttons.conf file, and put TPMode = notap.

Since Apple is still using the one button mouse and Linux window managers is relying on the right- and middle buttons, you'll probably need to bind a couple of keys to enable those functions again.

Enable "Emulated mouse buttons" in the kernel and edit /etc/sysctl.conf:

dev/mac_hid/mouse_button3_keycode = 96
dev/mac_hid/mouse_button2_keycode = 87
dev/mac_hid/mouse_button_emulation = 1

The first line binds the inverted "v" button left of the arrow keys to right-click, the second binds F11 to middle-click and the last line enables the emulation obviously.

To figure out keycodes start showkeys -m or xev and tap around.

Logging

By default Debian is configured with a pretty good logging facility, but you don't really need server like logging on a laptop. It's preferred to only log the most crucial information and discard the rest. This allows the hard drive to spin down and save precious battery power.

Open /etc/syslog.conf and edit the following entries (I've put the default as a comment):

auth,authpriv.*                 /dev/null
*.*;auth,authpriv.none          /dev/null
#cron.*                         /dev/null
daemon.*                        /dev/null
uucp.*                          -/var/log/uucp.log      

mail.info                       /dev/null
mail.warn                       /dev/null
mail.err                        /dev/null
news.crit                       /dev/null

news.err                        /dev/null               news.notice                     /dev/null

*.=debug;\
        auth,authpriv.none;\
        news.none;mail.none     /dev/null
*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
        cron,daemon.none;\
        mail,news.none          /dev/null

The rest of the entries that save to disk should have a "-" infront of the path to disable that the file is synced when a new line is appended.

See the files section below for a complete file.

Battery

Everyone wants the battery to last as long as possible when they're on the move. Here's a small list of Linux specific things to adjust to extend the battery life.

Keyboard

A new Debian install shouldn't have much problem with the keyboard. In the past kernels where configured with ADB keycodes but later switched to a more universal keycodes system.

If the kernel uses Linux keycodes (i386 actually), use dpkg-reconfigure console-data to configure the keyboard with the matching keymap.

Bluetooth

Kernel

Compile Bluetooth support into the kernel and the different features as modules, that way you can enable and disable the features you need. I selected L2CAP, RFCOMM, BNEP, and under device drivers HCI USB driver and HCI BMC203x driver. The BMC203x driver is required to load a new firmware to my D-Link DWB-120M adapter (Broadcom chipset).

Don't enable the Bluetooth support under the USB submenu, use the correct Bluetooth stack under the Networking submenu.

Installation

Install the BlueZ packages you need, find them using apt-cache search bluez. I installed the bluez-utils package and all the dependencies. In addition I need the bluez-firmware package for this adapter. Note that bluez-bcm203x is no longer required for kernel 2.6, the firmware driver included in the kernel now.

Drivers

Add the required modules to /etc/modules and they'll load on boot. It's only needed to add the main module, like rfcomm, and all the depencies will be loaded automatically. Since my D-Link adapter requires a firmware load, I need to install hotplug for the bcm203x driver to function correctly.

Testing

When the drivers are loaded, execute hciconfig to see if hci0 is up and running. If it is you can get some more information by executing hciconfig -a.

To discover bluetooth devices execute hcitool scan and then hcitool info xx:xx:xx:xx:xx:xx to get more information about the discovered device.

Pairing

If you use ppp a lot you probably don't want to enter pin codes every time you want to make a bluetooth connection to the phone. Pairing the machine with the phone creates a trusted relation that automatically allows new connections to the phone.

Method 1 - GUI

The first method is a bit more like the pairing process your're used to on Mac and Windows machines. A window appears when you are prompt to enter a pin code to allow the pairing.

Due to the way GUI access control works, the pin prompt window may not appear because of inadequate access rights. However, you can temporary disable the access control by running xhost + under the same user that the X window user. Note that this is not the proper way to getting the GUI running, remeber run xhost - right after you're finished to enable the access control again.

With that configured, set the phone to discoverable mode and execute rfcomm connect 0 xx:xx:xx:xx:xx:xx, where the xx's is the address of the bluetooth device. On the phone you'll be asked to either accept or pair the connection, select pairing and enter a random pin code. On the iBook a GUI will open and you'll be prompt to enter the pin code you just entered on the phone.

Method 2 - Command-line

If you don't have the X window system installed or just want to get the pairing done fast, use this method.

The first thing to do is creating is a script that spits out a static pin that you're going to use later. This simple script is all that's neccessary:

#!/bin/sh
echo "PIN:44233"

Of course, you can select you're own pin code. Make the script executable, chmod +x pincode.sh.

The next thing to do is edit /etc/bluetooth/hcid.conf and find the pin_helper line, comment it out and add this line:

pin_helper /home/ivc/pinscript.sh;

Restart the hcid daemon, /etc/init.d/bluez-utils restart, to commit the changes.

Now, set the phone to discoverable mode and execute rfcomm connect 0 xx:xx:xx:xx:xx:xx, where the xx's is the address of the bluetooth device. On the phone you'll be asked to either accept or pair the connection, select pairing and enter the pin code you used in the script above (e.g 44233).

Paired

If everything worked correctly you should be be seeing something like this:

Connected /dev/rfcomm0 to xx:xx:xx:xx:xx:xx on channel 1
Press CTL-C for hangup

The iBook is now paired with the phone and you don't have to make the phone discoverable or enter any pin code.

To make things simple, you can add the phone address to the rfcomm config file, /etc/bluetooth/rfcomm.conf, and use rfcomm bind 0 to enable the connection. Use rfcomm show to see if it's enabled. Disable it with rfcomm release 0. If bind yes; is added to the config the connection will be enabled on boot and ready to use whenever the the device is within reach.

rfcomm0 {
bind yes;
device 0:80:37:EE:E1:31;
channel 1;
comment "T68 Modem";
}

Most phones have more than one rfcomm channel and it can be handy to have another serial port ready, e.g if you want to enable a second Internet connection, upload files to the phone, etc. You can find out which channel you need to use by executing sdptool browse xx:xx:xx:xx:xx:xx|more and look at the class id.

PPP

Getting gprs and gsm running is pretty much straight forward. With PPP compiled in the kernel and the bluetooth connection is up, you only need to configure a set of ppp peers and chat scripts. Both under 10 lines.

These settings are tested and working with Telenor in Norway.

GPRS

The essential gprs settings is there's no carrier signal, no ppp echo packets and tcp header compression neccessary.

You can find the scripts in the files section below. For indepth explaination for the peers options, check the man pages (man pppd). And for the chat script check out the official modem scripts.

GSM

It's possible on most phones to use plain old analog dialup ppp connections to your isp. The settings isn't much different from regular modem setups. One thing I had to adjust was to put the authentication over to the binary stream (from ascii) after pppd got the CONNECT reponse from the host. If I didn't do that it would not continue the negotiation, it just returned all had bit 7 set to 0 and timeout.

Check the scripts below in the file section.

Modem

To get the modem working you have to find out if the moden is hardware or software based. Only the earliest iBook2 models have hardware modems. One way to figure out if you have a hardware modem is to check the boot log, /var/log/dmsg, and search for Z85C30. Thats's the PowerMac Zilog driver.

You need to enable the Zilog driver in the kernel to use the serial bus modem (ttyS0). Software modems however, are a bit more tricky because the Conexant modem driver was proprietary, so a new open source driver had to be written. There is a driver for the modem now but it's not included in the kernel because of licencing issues. You can get more installation information on this page.

The PPP configurations is virtually the same as for GSM, you only need to change the device path. The modem is located under /dev/ttyS0, and speed 115200 should work.

PAP Authentication

You can put the username and password needed to establish a connection in the /etc/ppp/ppp-secrets. The format is real simple, just like this:

username * password

Connect

To bring up the connection execute pon gprs/gsm/modem, and to bring it down execute poff gprs/gsm/modem or just poff. You can watch the log with plog and tailing /var/log/syslog (enable the log file again if you disabled it in the logging section above). You need to be in the dip group to bring up any connection when you're not root, adduser ivc dip.

Problems

To do

Files

xf86conf-4
kernel .conf
syslogd.conf
pbbuttons.conf
yaboot.conf
modules

Outputs

dmsg
cpuinfo
x-window-system
lspci

Essential links

Linux Install

Installing Debian 3.0 onto an Apple iBook [debian.org]
Installing Debian 3.0 on an iBook2 [hispalinux.es]
Installing Debian on a Apple iBook2 (mid-2002) [miketec.org]
Debian on a TiBook [neugierig.org]
Gentoo Linux PowerPC (PPC) install on Apple iBook 700MHz
[desertsol.com]
Debian GNU/Linux on an iBook 2.2 [bytebot.net]
Installing Debian 3.0 onto an Apple iBook2.2 [mega.ist.utl.pt]
Installing Debian GNU/Linux on a iBook 3.3 (G4) [seb.france.free.fr] *Updated*
Mij - Linux on iBook [mij.oltrelinux.com]
Running Linux on the ibook 700 [mayin.org]

Other

Wireless LAN und Linux [holtmann.org]
OpenBSD on my iBook [informatik.hu-berlin.de]
Linux on PPC tools [cederic.pradalier.free.fr] (fan control)
Bulma: Extend the battery life of your (iBook) laptop [bulma.net]
Debian SoundConfiguration [wiki.debian.net]
Linux Bluetooth and Nokia 6310i [hut.fi]
D-Link DWB-120M bluetooth adapter unter Debian [luug-hn.org]
PPP help (bit 7 set to 0) [lists.debian.org]
Linux GPRS Howto [turtiainen.dna.fi]
P800 and Linux [mobile.linux.pt]