Cross compiling the "Maui" kernel
As there definitly is a need for compiling an own kernel for my "Maui" project, I decided to set up a cross compiling
environment for compiling an ARM kernel form a x86 PC.
For cross compiling a so called "toolchain" is needed. There is lots of information on arm toolchains available on the
internet. As on building your own toolchain, as on prebuild toolchains.
The first way I found is an out of the box cross compiling environment based on Knoppix called "KernelKit".
This way turned out to be more complicated then setting up a toolchain on SuSE 9.3, so here I document the "SuSE
way".
Requirements:
- A SuSE 9.3 standard installation
- The "handheld" toolchain
- The kernel sources
Setup:
First download the handheld toolchain here. I use the gcc version 3.4.1 for the 2.6.14 kernel and gcc 3.3.2 for the
2.4.26 kernel, which can be found here.
Next get the kernel sources at http://www.kernel.org/. I took the version 2.6.14. as tar.gz file and the 2.4.26 as tar.gz.
Put the kernel sources on a standard SuSE 9.3 installation in a directory you like (e.g. /works). Now you need
to install the gcc, gcc-devel and ncurses-devel with "yast" on your system. The last step of the general setup is installing
the handheld toolchain. Just unpack it to / (you have to unpack to the root, because the toolchain uses absolute pathes).
Cross compiling:
Now everything is ready to compile.
The 2.4.26 and the 2.6.14 differ a lot in their compiling, so we have to differenciate:
2.4.26:
The reason I tested the 2.4.26 Kernel is that the Maui comes with an Epson S1D13806 graphics chip. The compiling of
the driver into the 2.4.26 kernel is very well documented at the Epson website. I put a copy of the documentation here.
The Epson Windows tool you will need to generate the s1d13806.h file can be downloaded here.
First setup the sources. You need to download these files:
Copy the files to the directory where your kernel sources are located (e.g. /works/linux-2.4.26) and apply the patches:
gzip -cd s1d13xxxfb-2.4.26.280905.diff.gz | patch -Np1
zcat patch-2.4.26-vrs1.gz | patch -p1
zcat linux-2.4.26-vrs1-pxa1.patch.gz | patch -p1
Next edit the top Makefile (/works/linux-2.4.26/Makefile) for cross compiling.
Comment out line 8:
#ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/a
Change line 22:
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/3.3.2/bin/arm-linux-
As the toolchain has troubles on compiling assembler code, we need to modify the file
/works/linux-2.4.26/arch/arm/Makefile. Edit line 43:
#arch-$(CONFIG_CPU_XSCALE) :=-D__LINUX_ARM_ARCH__=5 -march=armv4 -Wa,-mxsca
arch-$(CONFIG_CPU_XSCALE) :=-D__LINUX_ARM_ARCH__=5 -march=armv5te
line 56:
tune-$(CONFIG_CPU_XSCALE) :=-mtune=xscale
#tune-$(CONFIG_CPU_XSCALE) :=-mtune=strongarm
and line 61:
#AFLAGS +=$(apcs-y) $(arch-y) -msoft-float
AFLAGS +=$(apcs-y) -Wa,-mxscale -msoft-float
As we have our own mach type (878), we need to build the kernel especially for this mach type. Therefore first
edit the file /works/linux-2.4.26/arch/arm/tools/mach-types. Just append the following line:
maui MACH_MAUI MAUI 878
Next we make the Maui appear in the menuconfig menu. Inset on line 153 of
/works/linux-2.4.26/arch/arm/tools/config.in
dep_bool ' bSquare Maui' CONFIG_MACH_MAUI $CONFIG_ARCH_PXA
Now we can define the special behauviour of the kernel for the maui in
/works/linux-2.4.26/arch/arm/mach-pxa/Makefile on line 31:
obj-$(CONFIG_MACH_MAUI) += maui.o
and create a file called /works/linux-2.4.26/arch/arm/mach-pxa/maui.c
/*
* linux/arch/arm/mach-pxa/maui.c
*
* Support for the bSquare Maui.
*
* Author: Chris van der Meijden
* Created: Nov 12, 2005
* Copyright: Arachnon GbR
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/init.h>
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/bitops.h>
#include <asm/types.h>
#include <asm/setup.h>
#include <asm/types.h>
#include <asm/setup.h>
#include <asm/memory.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
#include <asm/arch/irq.h>
#include "generic.h"
MACHINE_START(MAUI, "bSquare Maui")
MAINTAINER("Chris van der Meijden")
BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
MACHINE_END
Now we can start the kernel configuration to create the .config file. You can either download my version (rename it
to .config and put it to /works/linux-2.4.26) or create your own by following the Epson driver document and checking
the "pxa25x" and "bSquare Maui" options. You can edit the configuration by typing
make menuconfig
at /works/linux-2.4.26
If you have a configuartion of your liking you will need the file s1d13806.h (cave: save in UNIX style!).
You can download mine or create your own with the Epson tool mentioned above. This file needs to be placed at
/works/linux-2.4.26/drivers/video/epson/s1d13806.h After that you can type (at /works/linux-2.4.26):
make dep
and
make zImage
The kernel should compile now.
2.6.14:
The compilation of the 2.6.14 is a lot easier. The disadvantege is that I don't now how the Epson driver behaves.
It is documented that all should run straight, but I'm wondering a bit about resolution, framerate and other settings.
Well, never mind. Here we go:
Unpack the kernel sources to, let's say, /works/linux-2.6.14 No patches are needed.
To modify the top Makefile for cross compiling edit line 192:
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux-
Implement the mach-type by editing /works/linux-2.6.14/arch/arm/tools/mach-types:
maui MACH_MAUI MAUI 878
and editing the file /works/linux-2.6.14/arch/arm/mach-pxa/Makefile on line 11:
obj-$(CONFIG_MACH_MAUI) += maui.o
Create the file /works/linux-2.6.14/arch/arm/mach-pxa/maui.c
/*
* linux/arch/arm/mach-pxa/maui.c
*
* Support for the bSquare Maui.
*
* Author: Chris van der Meijden
* Created: Nov 12, 2005
* Copyright: Arachnon GbR
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/sysdev.h>
#include <linux/major.h>
#include <linux/fb.h>
#include <linux/interrupt.h>
#include <asm/setup.h>
#include <asm/memory.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/udc.h>
#include <asm/arch/pxafb.h>
#include <asm/arch/mmc.h>
#include "generic.h"
MACHINE_START(MAUI, "bSquare Maui")
/* Maintainer: Chris van der Meijden */
.phys_ram = 0xa0000000,
.phys_io = 0x40000000,
.io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
.timer = &pxa_timer,
MACHINE_END
Make the Maui appear in menuconfig by editing the file /works/linux-2.6.14/arch/arm/mach-pxa/Kconfig by inserting
config MACH_MAUI
bool "bSquare Maui"
select PXA25x
on line 8.
Now we can start the kernel configuration to create the .config file. You can either download my version (rename it
to .config and put it to /works/linux-2.6.14) or create your own by checking the "pxa25x" and "bSquare Maui"
options. You can edit the configuration by typing
make menuconfig
at /works/linux-2.6.14
There seems to be a bug in binutils of the 3.3.2 toolchain, which makes the compilation stop. That is the reason I
use the 3.4.1 toolchain for the 2.6.14 kernel.
Now we can compile the kernel at /works/linux-2.6.14 with
make zImage
Resumé:
Neither the 2.4.26 nor the 2.6.14 Kernel boot at the moment. I believe that this is because of missing information about
irq and gpio handling in the file "maui.c", but this is still a guess. I would be very pleased if this little howto motivates to
setup a toolchain for the Maui. Any help is highly appreciated.
Both kernels bring an error while booting in "skyeye" (I will set up a webpage on this ARM emulator soon), if the wrong
mach type is used. So the setup for the mach type seems to be OK. As for the bootloader HaRET, I believe that it is
running OK too. You can download a kernel here which makes the phone LED of the maui turn red. This kernel
has nothing to do with the Maui and will never work, it just proves to me that HaRET actually starts a kernel.
It would be of great help, if we could see the kernel booting on a serial console. Info's on this are highly needed.
Update: I found the wiring for the serial interface! Here the link to the at-gm40x.pdf :-))
An other idea is to create a busybox initrd which does a "dmesg" on the storage card.
By the way. Please backup your Maui before starting any kernel with HaRET. The system goes in hard reset
afterwards. All data on the Maui will be lost and the Maui starts factory clean (the password is kept)!
Please feel free to contact me at maui@m-scene.de.
Lets have fun on Maui ...
Chris
Back to "Linux on the Vodofone Power Handheld (bSquare Maui)"
Last update: 11.24.2005