16. Cross Compiling a Kernel for the 5MX

It is usually not necessary to compile your own kernel. Binaries are available and so far they have been regularly updated as the kernel development proceeds. Should you want to dabble in, e.g., kernel development, however, here is the basic information on how to compile a kernel.

16.1. Prerequisites

There are four things you will need to gather together to compile a kernel for the 5MX:

  1. the ARM cross compiler (x MB)

  2. the kernel sources (about 30 MB)

  3. Russel King's generic ARM kernel patch (a few hundred KB)

  4. Tony L.'s Psion 5MX kernel patch (100 KB)

The sections below discuss how to go about obtaining these, and what to do with then once you've got them. The ARM cross compiler can also be used to compile other programs that will run on the 5MX.

16.2. The Cross Compilation Environment

Your own custom kernel can be created using the cross compilation environment. "Cross compilation" means using an i386 desktop computer to compile code that will run on the ARM computer. The cross compiler will also allow you to compile your own applications for the ARM system. To set it up, go to http://www.aleph1.co.uk/armlinux/book/x1768.html for some (now slightly out of date but still functional) info on available toolchains. I like the emdebian one best as the install is painless and operation is seamless.

These days, however, the scratchbox environment is probably the best way to go.

You can also download an 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.

16.3. Compiling a Kernel

Using the cross compilation environment described above, you can create your own kernel. To compile a custom kernel, you will need to download a kernel tarball - see http://www.aleph1.co.uk/armlinux/book/kernelcompile.html for some generic info on kernel building. You will need the base source code for the kernel, the ARM patch (rmk's), e.g., patch-2.4.18-rmk6.gz, and a 5MX patch.

I believe that as of 5/06 OpenPsion has adapted kernel 2.4.27 as their standard kernel, with 2.4.32 being the development kernel. Kernel 2.4.19 works fairly well as well.

The 2.4.27 kernel, prepatched for the 5MX, can be downloaded from http://svn.exactcode.de/linux24-psionw/ using subversion.

svn co http://svn.exactcode.de/linux24-psionw/ linux24-psionw
Subversion is a Debian package. I think this site tries to keep the 5MX kernel patchs uptodate. You can list the patches that have been applied by
svn log http://svn.exactcode.de/linux24-psionw/ 
or you can see the changelog on line at http://svn.exactcode.de/ChangeLog-linux24-psionw.

The 2.4.32 development kernel can be downloaded from http://www.woodall.me.uk/psion/psion.html where you can also get kernel 2.4.19.

If you want to start from scratch and apply all the patches yourself, the kernel source code can be obtained HERE, and the ARM patch can be obtained HERE. Then, get the 5MX patch for the kernel from http://linux-7110.sourceforge.net/files/Kernels/5mx_and_Revo/ - look for a file like: "linux-2.4.18-rmk6-5mx4.patch.gz" (this one would be for the 2.4.18 kernel, of course). Be sure that the kernel source, the ARM patch, and the 5MX patch all have the same version number - version 2.4.18 is used as an example here.

Assuming that you have downloaded these and copied them to a directory like $HOME/armkernel, execute the following commands:

cd $HOME/armkernel
gunzip linux-2.4.18.tar.gz
tar xvf linux-2.4.18.tar 
cd linux
patch -p1 < patch-2.4.18-rmk6
patch -p1 < linux-2.4.18-rmk6-5mx4.patch
These commands will patch the Linux kernel for use with the Psion Series 5MX.

You must now configure and compile the kernel. To configure it, execute:

make psion_5mx_ericsson_mc218_config 

[uk, us, or de keyboard types are now set by kernel configuration]

make oldconfig
then one of:
make xconfig
or
make menuconfig
or
make config
(in this context the latter is preferred as it only asks you about the new options and you just take the defaults for them all - the menu stuff just makes it more conplicated). You'll need to set your keyboard type - uk, us, or de (and a patch exists for the nordic keyboard).

Once you've prepared your source, make sure your linux/Makefile has

CROSS_COMPILE   =   arm-linux-
at about line 24; this should occur by default.

When you have done this, execute these commands to make the kernel:

make dep
make Image 
[NOT bzImage or zImage - kernels must be uncompressed!] This command will create a kernel image named "Image" in arch/arm/boot/ . This kernel image should then work as the kernel image to be loaded by ARLO.

16.4. Kernel Modules

The 5MX also supports modules, and the Sarge system includes all the utilities to handle modules. It may be that some of the more specific 5MX drivers are not supported as modules, however. But if you want to try modules, you can have a smaller kernel size and save a bit of memory.

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. Initially, you may have to execute "depmod -a" on your new system to get modules to work properly, and be sure the modules files are owned by user root, group root ("chown -R root.root /lib/modules/*" will fix that, if not).