Cross-Compile for Armel Using an ARM HF VM

craig arm-based netbook running debian

Preface

This method of compiling for armel (e.g. ARMv5, earlier, and some ARMv6) which uses pbuilder in an ARM HardFloat VM is not recommended as it is extremly slow (because of running in a emulated VM, not because of using pbuilder), but is included for completeness.

You Need an ARM HardFloat VM

Build and boot an ARM HardFloat VM created using one of the methods pointed to by Four ARMs for LibVirt KVM

Install and Configure pbuilder

sudo apt install pbuilder

Create a pbuilder rootfs

For example, if you want to build in a ‘wheezy’ armel environment:

  1. mkdir pbuilder-wheezy
  2. mkdir pbuilder-wheezy/tmp
  3. mkdir pbuilder-wheezy/cache
  4. mkdir pbuilder-wheezy/aptcache
  5. The main build command:
    sudo pbuilder create --basetgz pbuilder-wheezy/base.tgz --buildplace pbuilder-wheezy/tmp --buildresult pbuilder-wheezy/cache --distribution wheezy --architecture armel --aptcache pbuilder-wheezy/aptcache --mirror http://archive.debian.org/debian
    

Add Additional Packages to pbuilder as Required

  • This article takes this approach in order to illustrate how to add packages to an existing pbuilder rootfs because this workflow occurs often.
  • You could use --extrapackages in the pbuilder command above if you already know what packages you need.
  • To add packages like ‘make’ and vim-nox to an existing rootfs you might use: >
    sudo pbuilder update --basetgz pbuilder-wheezy/base.tgz --buildplace pbuilder-wheezy/tmp --buildresult pbuilder-wheezy/cache --aptcache pbuilder-wheezy/aptcache --extrapackages "make vim-nox" 
    

Build Kernel (for example)

Get a Copy of a 2.6 Kernel

In our case we’re going to clone the build system and linux 2.6 kernel from my WM8650 repo:

git clone -b wmcshore-1.0 --depth 1 --recurse-submodules https://git.danielfdickinson.ca/linux-kernel/wm8650-2.6-reference-kernel-build.git --shallow-submodules  wm8650-2.6-reference-kernel-build

Use pbuilder to build the kernel

  1. Launch a pbuild ‘login’ with the kernel build directory bind mounted into the pbuilder chroot:
    sudo pbuilder login --basetgz pbuilder-wheezy/base.tgz --buildplace pbuilder-wheezy/tmp --buildresult pbuilder-wheezy/cache --aptcache pbuilder-wheezy/aptcache --bindmounts "$(pwd)/wm8650-2.6-reference-kernel-build"
    
  2. In pbuilder login, change to your wm8650-2.6-reference-kernel-build directory. (e.g. cd /home/user/wm8650-2.6-reference-kernel-build).
  3. Build the kernel (for this example all that we need to do is execute make).
  4. Wait (a long time).
  5. Once you are done, exit the login session.

Copy the Build Artifacts

Copy artifacts (aka output/reults) to where you can use them (this is just standard Linux copying or remote copy, etc).

By Daniel F. Dickinson

Daniel Dickinson has been using and exploring computer and electronic technologies for over three decades. He is proficient with various flavours of Linux (including varieties of desktop, server, and embedded systems) as well as modern Windows. Daniel still enjoys software and firmware development, but prefers integration and extending existing open source solutions to quickly achieve desired goals. Fo more details see https://www.wildtechgarden.com/about/about-daniel-f

Leave a comment

Your email address will not be published. Required fields are marked *