19. Recipe for Compiling the Kernel

Here, in brief, are the steps to assemble the pieces to compile your own version of the linux kernel for the netBook. The cross-compiling environment can be set up in less than an hour or so (and you have the marginal benefit of notes polished in response to my experience!).

For those of you with lots of disk space on your netBook, note that you can compile the kernel and its modules directly on the netBook. This does not take THAT long, all things considered - 1-2 hours. To do this, you will of course need to install make and gcc on your netBook, in addition to the kernel source. But it saves you having to install and set up the cross-compiling environment. When compiling the kernel, it is recommended to stop all other processes, including X windows. The main potential problem is lack of memory during the compile process.

19.1. Preferred Cross-compiler: Scratchbox

The cross compiler that seems to be preferred by openpsion developers is scratchbox at www.scratchbox.org, which is a complete x-compiling environment. This has a fairly easy installation, with a set of rpm or deb packages, depending on the system you want. Scratch box now has a fairly uptodate compiler (gcc version 3.3.4) which has been verified compile a functioning the kernel binary for kernel version 2.4.27. Scratchbox is contained within a large virtual file system, and I've found you have to login to the virtual system to use the compiler on kernel source. You may need a fast internet connection (or a lot of patience) to get it and loads of free diskspace to unpack it. I installed the following packages:

After installing, get an ARM cross compiling system set up (I am a little confused by all this too, but I managed to muddle through to something that worked).

19.2. Qemu and Debian Linux - a Complete Emulated System

You can now use the Qemu emulator to emulate a complete ARM system. The emulated system does not support PCI or hard disks, so a network/NFS boot has to be employed. You can see instructions for how to set up the network system boot, or download a complete debian system from emulated Debian ARM system. This is a complete Debian Sarge system for ARM processors emulated using qemu. This is not technically a cross-compiler, but a native compiler. This system is easy to install and easy to use, but has the one downside that it runs a slower than, e.g., scratchbox. It has the advantage that since it really is Debian Sarge, compiled binaries can be tested, and are guaranteed to work, on a Debian Sarge system used on the Psion - there will be no library issues.

Qemu could also be used to compile a system for the netbook from scratch, e.g., to optimize for floating point.

19.3. Cross-compiler Alternative: The emdebian cross compiler for Debian Woody

- follow instructions on emdebian website (www.emdebian.org) (entry in /etc/apt/sources.list)

- apt-get install task-cross-arm

this leads to one error message "couldn't find /usr/share/info/iostream.info.gz". Fix this error using: "ln -s iostream-295.info.gz /usr/share/info/iostream.info.gz"

These tools can also be set up on rpm-based systems. Get the rpm's from http://www.emdebian.org/tools/crossdev.html. You'll need something these (now deprecated, no doubt):

  1. binutils-arm-

  2. cpp-arm-2.95.2-12e4.i386.rpm

  3. g++-arm-2.95.2-12e4.i386.rpm

  4. gcc-arm-2.95.2-12e4.i386.rpm

  5. libc6-dev-arm-2.1.3-8e4.noarch.rpm

  6. libstdc++2.10-arm-2.95.2-12e4.i386.rpm

  7. libstdc++2.10-dev-arm-2.95.2-12e4.i386.rpm

These rpm's did not install properly with rpm on my RedHat 9.0 system, but it was fairly easy to unpack and install them by hand. Put the rpm's in their own directory and for each file (a) unpack it with "rpm2cpio filename.rpm > temp", (b) then unpack the cpio "temp" file with "cpio -i < temp". This will make a directory "usr" with the stuff in it. Then tar the usr directory over to the system files " tar cf - usr | (cd / ; tar xf - )". (This has not noticeably cause my RedHat system to become non-functional...it's o.k....) The cross compiler (x-compiler) is then available.

19.4. Get kernel files and patches

The versions of all of these files changes fairly regularly; get the most recent ones!

  1. linux-2.4.27.tar.bz2 from www.kernel.org (Here)

  2. patch-2.4.27-vrs1.bz2 from www.arm.linux.org.uk (Here)

  3. patch-2.4.27-vrs1-kvd1 from www.psilinux.org (Here)

    (This patch gives the options of 16, 32, or 64 MB of memory; but use the default 16 MB.)

Put all these files in a directory "some/sourcedir/with/files/"

19.5. Compile

Unpack the kernel source, apply the patches, configure the kernel:

  1. cd some/sourcedir/with/files/

  2. tar -xjvf linux-2.4.27.tar.bz2

  3. cd linux

  4. zcat ../patch-2.4.27-vrs1.gz | patch -p1

  5. cat ../patch-2.4.27-vrs1-kvd1 | patch -p1

  6. make mrproper

  7. make netbook_config

  8. make oldconfig (experts can then do "make config", or "make xconfig" to customize the options)

  9. make dep; make clean

Now log in to the scratchbox system and compile:

  1. make zImage

Copy the arch/arm/boot/zImage file to the compactflash card and it should boot up your netBook.

19.6. Compiling and Installing Modules

You will likely configure the kernel to use kernel modules. [From http://www.arm.linux.org.uk/docs/kerncomp.shtml#crossinstall]:

After make modules, install the modules into /usr/src/arm/ [or some other directory] as follows:

bash$ make modules_install INSTALL_MOD_PATH=/usr/src/arm/

If your kernel version is x.y.z, this command will place the modules into the /usr/src/arm/lib/modules/x.y.z directory on the host, which can then be placed into an suitable filesystem, or transferred to the target machine. (note that /usr/src/arm/lib/modules/x.y.z should become /lib/modules/x.y.z on the target machine). Please also note that you should not install these kernel modules into the hosts root filesystem, since they are incompatible with your host kernel.

However, within the scratchbox virtual environment, a "make modules_install" will just safely put the modules in the virtual /lib/modules directory of the virtual environment.

You will also need the module utilities programs (modutils) in your filesystem to manage the modules.