Linux4Palm Development Workstation on Gentoo Linux

I'll be assuming you've got an up to date Gentoo install on x86 hardware. Most of this will also work on x86_64 but you may need to tweak some things.

Revision Control Systems

You're going to be using a whole stack of these. The most common you'll encounter will probably be CVS, Subversion and git.

sudo emerge -av --noreplace cvs subversion cogito

For OpenEmbedded (ie OpenZaurus, Angstrom etc) you will need a very specific version of Monotone, as of this writing that's v0.32 but check the OpenEmbedded site for updates. Note: They may say v0.32 or later, but you may have problems if you use a higher version, use the exact same version they use and you should be ok. v0.32 is currently masked, so add to /etc/portage/package.keywords:

dev-util/monotone ~x86

Then install it:

sudo emerge -av =dev-util/monotone-0.32

OpenEmbedded

Have a read of the official guide. I'll give a very brief overview of my setup.

First, create a directory to store all your OE-related stuff:

mkdir -p ~/Projects/palm/oe
ln -s ~/Projects/palm/oe ~/oe
cd ~/oe

Next, start downloading the latest snapshot of the metadata tree. This is over 100mb so will take a while on most connections, so start it now and continue the guide.

wget http://www.openembedded.org/snapshots/OE.mtn.bz2; bunzip2 OE.mtn.bz2

Grab the latest version of bitbake too:

svn co http://svn.berlios.de/svnroot/repos/bitbake/branches/bitbake-1.8/ bitbake

Create a small script to setup PATH and other environment variables for doing OE work. I call this ~/oe/env.sh:

export OE="$HOME/Projects/palm/oe"
export PATH="$OE/bitbake/bin:$PATH"
export BBPATH="$OE/build:$OE/org.openembedded.dev"

Before doing any OE work, just source this into your shell. Do it now:

source env.sh

Now you'll have to wait for OE.mtn to download and uncompress. Go chat on IRC for a while or something. Once it's done we check out a working directory:

mtn --db=OE.mtn checkout --branch=org.openembedded.dev

Now create local.conf which specifies amongst other things what distro and machine you're building for:

mkdir -p build/conf
cp org.openembedded.dev/conf/local.conf.sample build/conf/local.conf
vi build/conf/local.conf

Make the following changes:

DL_DIR = "${OE}/downloads"
BBFILES := "${OE}/org.openembedded.dev/packages/*/*.bb"
MACHINE = "palmld" # or whatever
DISTRO = "angstrom-2007.1"
IMAGE_FSTYPES = "tar ext2"
PARALLEL_MAKE = "-j3" # if you have multiple CPUs/cores
INHERIT = "package_ipk"

Choose one of

# TARGET_OS = "linux"
# TARGET_OS = "linux-uclibc"

Also take out the last line of the file that will cause it to abort.

[Optional] Install Psyco

Psyco is a JIT-compiler for Python that speeds up bitbake's parsing a bit. If you're on x86, it's probably a good idea to install it:

sudo emerge -av psyco

[Optional] Http-Replicator

As a Gentoo user you probably have source tarballs for loads of stuff sitting around in your distfiles directory. Instead of re-downloading everything for OE, install Http-Replicator. Then add to your environment:

export http_proxy="http://localhost:8080/"
export GNU_MIRROR="http://www.planetmirror.com/pub/gnu"
export DEBIAN_MIRROR="http://mirror.optusnet.com.au/debian/pool"
export SOURCEFORGE_MIRROR="http://optusnet.dl.sourceforge.net/sourceforge"

We change some of the common mirrors to http as ftp will bypass Http-Replicator.

Now get building

Now try building something:

bitbake angstrom-console-image

Bitbake may tell you that you're missing some tools (for instance diffstat and texi2html) just emerge them and try again:

sudo emerge -av diffstat texi2html
bitbake angstrom-console-image

You'll probably find that the qemu-native package fails to build, complaining about requiring gcc 3.x. Simply install a version of gcc 3:

sudo emerge =sys-devel/gcc-3.4.6-r2

Then switch to it temporarily and build qemu:

sudo gcc-config --list-profiles
sudo gcc-config i686-pc-linux-gnu-3.4.6
source /etc/profile
source env.sh
bitbake qemu-native

Switch back to your normal compiler and continue building your distro image:

sudo gcc-config i686-pc-linux-gnu-4.1.1
source /etc/profile
source env.sh
bitbake angstrom-console-image

For building userfriedly linux image add in build/conf/local.conf (more and fresh info at http://linuxtogo.org/gowiki/OpieWithAngstrom)

require conf/distro/include/preferred-opie-versions-1.2.3-pre.inc

and try

bitbake opie-image

Linux Kernel

While OE will automatically build a kernel for you, it's often useful to be able to compile the kernel manually while developing.

First then we need is a toolchain. You've got several options for this you could use OE's toolchain, build one with Gentoo's crossdev script or use someone else's pre-compiled one. I'll describe the first two options.

Use OpenEmbedded's toolchain

This is the easiest option. You should find the toolchain binaries under oe/tmp/cross/bin. All you have to do for the linux kernel to use them is set a couple environment variables.

export CROSS_COMPILE=$HOME/Projects/palm/oe/tmp/cross/bin/arm-angstrom-linux-gnueabi-
export ARCH=arm

Put them into a shell script if you like:

mkdir ~/Projects/palm/linux
vi env.sh

Build a custom toolchain with crossdev

Portage contains a neat script which makes building custom toolchains really easy.

sudo emerge -av crossdev
sudo crossdev -t arm-softfloat-linux-gnueabi

To see what other options are available try:

sudo crossdev -t help

Once your toolchain is built, we'll of course need to tell the kernel to use it. Again just set these environment variables:

export ARCH=arm
export CROSS_COMPILE=arm-softfloat-linux-gnueabi-

Building the kernel

Start as usual by checking out the kernel from subversion.

mkdir -p ~/Projects/palm/linux
cd ~/Projects/palm/linux
svn co https://hackndev.svn.sourceforge.net/svnroot/hackndev/linux4palm/linux/trunk linux-hnd
cd linux-hnd

Make sure you have the toolchain environment variables set as explained in the previous sections then type:

make help

Look for your machine in the resulting list.

make palmld_defconfig
make

When the build process completes, the resulting zImage will be in arch/arm/boot/zImage.

Bootloaders

Now that you've got an OpenEmbedded build environment and the kernel, the next thing you might like to be able to build is a bootloader. For this we will need the Palm OS SDK.

Palm OS SDK and PRC Tools

x86_64 users: You'll probably need to do this in a 32-bit chroot or virtual machine. prc-tools uses a really old version of gcc which gets confused by x86_64.

You should have installed a GCC 3.x compiler above. If not do it now:

sudo emerge =sys-devel/gcc-3.4.6-r2

You need to use gcc 3.x to build the ARM portion of prc-tools. So switch to it and then emerge prc-tools.

sudo gcc-config --list-profiles
sudo gcc-config i686-pc-linux-gnu-3.4.6
source /etc/profile
sudo emerge -av prc-tools

Don't forget to switch back to your normal compiler, afterwards.

sudo gcc-config i686-pc-linux-gnu-4.1.1
source /etc/profile

Unmask the SDK ebuild by appending to /etc/portage/package.keywords:

dev-lang/palmos-sdk ~x86

Hunt around on the ACCESS developers site until you find palmos-sdk-5.0r3-1.tar.gz and PalmOS_5_SDK_68K_R3_no-install.zip. Drop them in /usr/portage/distfiles.

Then install the palmos-sdk and pilrc packages as per usual.

sudo emerge -av palmos-sdk pilrc

Great, now you should be able to compile the bootloaders.

Cocoboot

Checkout Cocoboot from Hack&Dev subversion.

mkdir -p ~/Projects/palm/bootloaders
cd ~/Projects/palm/bootloaders
svn co https://hackndev.svn.sourceforge.net/svnroot/hackndev/cocoboot/trunk/ cocoboot

Then compile as per the README file's instructions.

cd cocoboot
make

Copy the resulting cocoboot.prc to your Palm's memory card or HDD, along with a kernel zImage and optionally an initrd.gz image.

BFUGarux

Checkout BFUGarux from Hack&Dev subversion.

mkdir -p ~/Projects/palm/bootloaders
cd ~/Projects/palm/bootloaders
svn co https://hackndev.svn.sourceforge.net/svnroot/hackndev/linux4palm/BFUGarux

Edit the Makefile and remove the -palmos option from LDFLAGS.

Grab a kernel zImage and initrd.gz from somewhere. If you do not need an initrd, just make an empty file.

cd BFUGarux
cp ~/Projects/palm/linux/linux-hnd/arch/arm/boot/zImage .
touch initrd.gz

Then compile as per the README file's instructions.

make palmld BFU