Next Previous Contents

4. Compiling a new kernel

4.1 IMPORTANT Note

When I first installed Linux and began to compile a new kernel, I was surprised to see that the laptop remained very silent. I did not know about the therm_adt7467 module, later when I tried, I heard the fan whenever I would compile a kernel, so it is highly advised to compile it.

(See Thread therm_adt746x on debianppc Mailing List)

4.2 Complementary modules tools

In order to avoid errors like this with your future kernel, when using lsmod:

pomme:~# lsmod
Module                  Size  Used by    Not tainted
lsmod: QM_MODULES: Function not implemented

install the package module-init-tools
(apt-get install module-init-tools)

4.3 Retrieving the sources

The process from this point forward should be much simpler now, since the latest Mac port is in the mainstream kernel.

Many people I have spoken to suggested that we should not build the kernel in /usr/src, for security issues, so I will teach you 'the right way' directly, as shown below:

Create an unprivilieged user account (using adduser)

I called it 'seb'.

cd /home/seb

rsync is no longer recommended, you should use the kernel from kernel.org
Download a kernel from kernel.org, currently the most up to date is:
ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.3.tar.bz2

tar xjvf linux-2.6.3.tar.bz2 && cd linux-2.6.3

Install libncurses5-dev in order to be able to use menuconfig and kernel-package in order to build it and put it into a debian package:
apt-get install libncurses5-dev kernel-package fakeroot

make pmac_defconfig
(Otherwise you may get lots of 'IN from bad port 64 at c013ccac' at top of your dmesg, detailed explanation follows)
make menuconfig

If you get lots of "IN from bad port 64 at ...", here is the reason :

The dmesg buffer overflows with an error. This error is caused by your .config having a bogus ISA driver.
Remove the legacy PC/AT keyboard controller driver from your .config.

Benjamin Herrenschmidt

4.4 Kernel configuration

In this section, I will only expand on iBook items, you should be able to find the rest of the material shown below wrapped up in the formal .config.

Processor

Select Processor Type (6xx/7xx/74xx/8260)

and enable

Altivec Support (more info)

Thermal Management Support and Average high and low temp will not work, disable them.

CPU Frequency scaling works, enable if you want to be able to control your CPU frequency.

CPU Frequency scaling

Set Default CPUFreq governor to userspace
(otherwise the frequency scaling will be set statically to the highest possible)

You should enable 'performance' governor and 'powersave' governor along with /proc/sys/cpu/ interface (2.4 / OLD) and Support for Apple PowerBooks.

Workarounds for PPC601 bugs should not be needed (Carlos)

Platform Options

Machine Type (CHRP/PowerMac/PReP)

Enable Support for Open Firmware device tree in /proc (It will give an image of the device tree reported by Open Firmware)

Device Drivers

ATA/ATAPI/MFM/RLL support

You should probably Include IDE/ATAPI CDROM Support as a module otherwise it will check if a cd is inserted and accelerate the drive every-time you boot.

Enable Built-in PowerMac IDE support

Probe internal ATA/100 (Kauai) first

PowerMac IDE DMA support

Use DMA by default

from geekounet.org : therm_adt7467 #fan control (I use fan_speed=128 )

Networking support

Ethernet (10 or 100Mbit)

Enable Ethernet (10 or 100Mbit)

Sun GEM support

Character devices

/dev/nvram support

Now, enable these as Modules (we need to load them in a precise order)

/dev/agpgart (AGP Support)

Apple UniNorth AGP Support

Enable Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) and select ATI Radeon as a module

I2C support

I2C support

I2C Hardware Bus support

Powermac Keywest I2C interface

Graphics support

Support for frame buffer devices

ATI Radeon display support

Sound

Enable Sound card support

PowerMac DMA sound support

Advanced Linux Sound Architecture

Enable Advanced Linux Sound Architecture

OSS API emulation

OSS Mixer API (/dev/mixer*)

OSS PCM (digital audio) API (/dev/dsp*)

ALSA PowerMac devices

Enable PowerMac (AWACS, DACA, Burgundi, Tumbler, Keywest)

USB support

Use EHCI HCD support (USB 2.0) and OHCI HCD support (USB 1.1).

File systems

Miscellaneous file systems

You may want to enable the EXPERIMENTAL Apple Macintosh file system support (HFS and HFS+ aka extended).

Kernel hacking

Enable Support for early boot text console (BootX or Open Firmware only)

4.5 Packing the kernel

fakeroot make-kpkg binary-arch
(It is a Debian command, do not be surprised, it will build your kernel into a .deb file)

I do not know why but initrd do not seem to be as widely used as on PC (no need for --initrd). (see the initrd section)

dpkg -i ../kernel-image*

(Make sure there is only one kernel package, when updating)

Enabling the ATA100 option (CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST), will switch hda and hdc :

With the kernel of the installation:
CDROM->hda
HDD->hdc

And after reboot:
HDD->hda
CDROM->hdc

So you should run into a problem when you will reboot, such as the following message:

VFS: Cannot open root device "hdc5" or unknown-block(0,0)
Please append a correct "root=" boot option
Kernel panic: VFS: Unable to mount root fs on unknown-block(0,0)
 <0>Rebooting in 180 seconds...
You can reboot immediatly using ctrl+apple+power, then when you get to the second stage yaboot prompt type this:
Welcome to yaboot version 1.3.11
Enter "help" to get some basic usage information
boot:
Linux root=/dev/hda5 (it is an American keyboard layout, the = is on the left from backspace, / is on the left from the right Shift)

You should now see the following message like this:

Checking root file system...
fsck 1.35-WIP (31-Jan-2004)
fsck.ext3: Read-only file system while trying to open /dev/hdc5
Disk write-protected; use the -n option to do a read-only check of the device.

fsck failed. Please repair manually and reboot. Please note that the root file system is currently mounter read-only.
To remount it read-write:

        # mount -n -o remount,rw /

CONTROL-D will exit from this shell and REBOOT the system.

Give root password for maintenance
(or type Control-D for normal startup):
Type in your root password

mount -n -o remount,rw /

Now, edit /etc/fstab and /etc/yaboot.conf, replace any instance of /dev/hdc* by /dev/hda*, except the line starting by "boot=/dev".

Do not forget to run ybin -v.

Cross fingers and reboot :]

If you have had a successful install, you should hear a beep noise when keeping down backspace.

4.6 PowerPC specific stuff about the kernel

Initrd

(the following is an irc chat transcript from #debian-powerpc)

<sebfrance> demon: why initrd are not used on mac ?
<demon> sebfrance: because kernel size limitations aren't present, because no one gives a rat's ass about floppy boot,
except on oldworld/old chrp systems
<demon> er, chrp/prep systems
<demon> you can do an initrd
<demon> in fact, for booting off usb or firewire, it's a must
<demon> but for booting off a hard drive, it's not much of an issue
<demon> plus, the number of IDE and SCSI controllers you run into on PPC is less variant than what you run across on x86
<demon> it's usually a pretty short list
<sebfrance> so you can directly build them in the kernel ?
<demon> yep

Comparison with x86

<xsnapcasex> why in x86 the location is arch/i386/boot/bzImage
<xsnapcasex> and in ppc is in the same path where kernel is compiled
<demon> because x86 can't load a raw kernel directly, because the system boots in real mode
<xsnapcasex> my english level is low, sorry
<demon> but powerpc can
<xsnapcasex> ok
<demon> on x86, you have to either (a) load the kernel into low memory, then jump to the setup routine that uses the a20 gate to push
uncompressed pages into extended memory, jump to protected mode, and jump to the kernel entry point, or (b) have your loader switch
into protected mode, decompress the kernel, and jump into it
<demon> where on ppc, you load the kernel, and jump to its entry point, because it's always in protected mode


Next Previous Contents