Printable Version of Topic

Click here to view this topic in its original format

OESF Portables Forum _ Zaurus - Arch Linux ARM support _ Cross Compiling Arch Packages On Arm Platforms

Posted by: danboid Oct 31 2015, 05:59 AM

Over a decade after its launch, the Zaurus is still a useful pocket computer but its 64MB RAM limitation can be restrictive, especially when it comes to building large programs. The Zaurus simply doesn't have enough RAM to compile some large source files and it just enters 'swap hell' when it gets overwhelmed. On top of this, the Zaurus is slow to compile programs it can manage so it can be a huge time saver to get a cross-compilation environment set up which enables you to utilize more powerful machines to accelerate or simply enable the building of complex software.

The cross compilaion method recommended by the ALARM developers and ultimately the fastest way to cross compile software is to use distcc. In most cases you should try setting up distcc by following the ALARM developer distcc guides first before you resort to the ARM cross compiling method described here.

To use this guide you need to be familar with the Arch package management tools and you need an ARM-based computer running ALARM that has superior specs to the Zaurus and internet connectivity so that it can download development packages. If you don't already own a modern ARM computer and you're on a tight budget then I can highly recommend the Banana Pi, which is about the same price as the RPi2 but with SATA2 and gigabit ethernet. It's not officially supported by ALARM, like the Zaurus, but also like the Z it runs ALARM very well nonetheless. If you have more money to spend you might want to check out something like the Odroid XU4 which has 2GB RAM, a faster CPU and USB3. Check out for a list of supported platforms.

The key bit of software used in this guide is arch-chroot which is part of the arch-install-scripts package. I have only tested chrooting from an Arch armv7 userland into an Arch armv5 but you could probably run arch-chroot under another modern ARM Linux distro that uses systemd and get the same results. To keep things simple it is recommended you stick to ALARM for the host OS but I'm interested to hear from anyone who tries this under a non Arch-based ARM Linux distro. This guide should work for machnes running armv6h and aarch64 too.

First you need to download and extract the ALARMv5 rootfs:

$ wget
$ mkdir ~/ALARMv5
# bsdtar xvf ArchLinuxARM-armv5-latest.tar.gz -C ~/ALARMv5

Note that the extraction of the rootfs (the bsdtar command) needs to be done as root to preserve the files users and permissions but otherwise you can extract it where you wish.

Presuming that the host machine is connected to the internet, copy the host machines resolv.conf into /etc of the chroot fs:

# cp /etc/resolv.conf ~/ALARMv5/etc

You should now be able to chroot into the ALARMv5 rootfs:

# arch-chroot ~/ALARMv5

Now you're logged into the chroot, you can build Arch packages just as you normally would but there are two main things you should check when configuring an Arch package for cross compilation.

First you need to check the 'arch' statement in the PKGBUILD script for the package you are building includes 'arm'. If it doesn't then add it in so that the arch line looks like:

arch=('i686' 'x86_64' 'arm')

If the package you are building uses autoconf with a configure script then you need to add the correct --build switch option to the ./configure statement within the build() function of the PKGBUILD script to make sure the compiler builds for armv5 instead of armv7 or whatever platform your host is running. It will look something like this after modification:

build() {
  cd $srcdir/$pkgname-$pkgver
  ./configure --prefix=/usr --build=armv5tel-unknown-linux-gnueabi || return 1
  make || return 1

You might have to do some investigation to work out how to tell your app to build for armv5tel-unknown-linux-gnueabi if it doesn't use autoconf. You can often set the arch to build for by exporting it as an environment variable but I wouldn't worry too much about trying to specify the target build arch as in most cases the resultant packages will work regardless.

Providing you have enough disk space I would recommend you install your packages under the chroot after they have finished building. Not only does ths act as a test of ther validity but it is a backup too should you quit out of the chroot before backing the package up.

makepkg, packer and pacaur etc store the finished package under /tmp directory. packer for example stores its packages under /tmp/packerbuild-0/$PKGNAME/$PKGNAME where $PKGNAME is the name of the package you built. Make sure you copy the package out of the /tmp dir of the chroot after building and before you exit the chroot because everything under /tmp gets deleted as soon as you exit the chroot, which you do by typing 'exit' or hitting CTRL+D.

If you do ever need to create an Arch package from one that was previously installed but for which the package no longer exists (for example if you quit out of the chroot before copying the package out of /tmp) then you can use bacman to create the package, which comes as standard with pacman. Using it is as simple as running:

$ bacman packagename

Posted by: danboid Oct 31 2015, 06:44 AM

If anyone does decide to get themselves a Banana Pi as an ALARMZ build box, you have to upgrade the kernel from ye olde 3.4 thats included with the BPi Arch distros to be able to use arch-chroot.

Not to blow my own trumpet too over-zelously but dontchyathink this thread deserves a sticky award Archi of Mark? biggrin.gif

Posted by: danboid Nov 1 2015, 03:36 AM

I've changed the title of ths guide, added a mention of the package that needs to be installed for arch-chroot (arch-install-scripts) and added that this should work for armv6 (the original RPi) and aarch64 too eg the Nvidia Shield devices.

Posted by: danboid Nov 1 2015, 04:35 AM

Added note about using bacman to create packages from previously installed ones.

Posted by: ArchiMark Nov 1 2015, 06:50 PM

QUOTE(danboid @ Oct 31 2015, 07:44 AM) *
Not to blow my own trumpet too over-zelously but dontchyathink this thread deserves a sticky award Archi of Mark? biggrin.gif

Yes, indeed, Dan of Boid......


Posted by: ArchiMark Nov 6 2015, 07:40 AM

Hope it's OK to post this here.....if not, let me know and I'll move it.....

Looking ahead to hopefully getting X and window manager running OK......

So, one program I'd like to use is notecase pro. See

The developer, Miro, used to support the Zaurus, but no longer. I explained that it's now possible to run ALARMZ on it....if you look on his downloads page, he has a package file for Arch (for x86 machines).

He said the following regarding getting a build that would work on Zaurus with ALARMZ:

I can try to dig the last build for Zaurus from backups, so you can try to see if it can be used.

The problems with restarting builds for Zaurus are:

- I don't have hardware to build on

- I don't think you can use VirtualBox or VMWare to run ARM related distro

- I am not aware of QEMU virtual image for this platform

So, basically, I don't have means to run this platform.

If you can create QEMU image for this platform (that can run on Windows, like for example this project for Pi: I could try supporting it.

Do you think a QEMU image is possible for this?

Would be great to get notecase pro on my Z.....


Posted by: danboid Nov 7 2015, 06:29 AM

As I said in IRC, qemu can emulate a Z but I've been told by the ALARM devs its not reliable for compiling software so you'll have to see if the dev of that app has another ARM machne such as an RPi that they might be able to installl ALARM onto and use this guide to build for the Z.

Posted by: daalnroti Nov 9 2015, 11:30 PM

QUOTE(danboid @ Nov 7 2015, 03:29 PM) *
As I said in IRC, qemu can emulate a Z but I've been told by the ALARM devs its not reliable for compiling software so you'll have to see if the dev of that app has another ARM machne such as an RPi that they might be able to installl ALARM onto and use this guide to build for the Z.

That is actually a good point. The qemu emulation is not suitable for development.

To compile apps, the best is to do natively or on another ARM platform that has armv5tel support. Distcc works, but is not that much faster.

For kernels you can do a cross compile using the toolchain provided by ALARM. This toolchain can be used to compile some apps too, depending on their dependencies. smile.gif

Would be good to continue sharing any PKGBUILDs or tar.xz files for custom packages made for the Z, or at least the source, here in the forum or on github.

Thanks for contributing and keep up the work. We are making quite some progress so far. A few more users would be good for testing...

Powered by Invision Power Board (
© Invision Power Services (