Thursday, February 02, 2012

 

Setting up ARM chroot on Ubuntu Oneiric (11.10) for cross build

I recently ordered a Pandaboard ES so that I could learn a few things on ARM development. A caveat on ARM development, if you are going to compile anything on the device it takes significant time. When I am new to a platform, to gain experience, I build a bootable Linux kernel and install it. This lets me get a hang of recovering to a known working kernel if something screws up during a kernel upgrade. I started out building the kernel directly on the device but was bitten by a known bug which results in segfaults/sigbuses when running the Pandaboard using the entire 1GB of RAM it has. The workaround is to change the boot parameters so that only 768MB of 1GB of RAM is used. Considering the fact that it takes significant time to build things on the device, I thought why not use my old Pentium M laptop as cross compile build box. The first thing for that is to install a working ARM cross chroot environment. I contacted my good friend Google as ever. I found a lot of useful resources as usual. I thought I would document the approach that I used which worked for me.

I used EmDebian CrossDebootstrap wiki entry [1] as the starting point. I installed Ubuntu's Oneiric ARM port in the chroot and the steps are as follows:
  1. First and foremost is to install some of the required packages
    # apt-get install binfmt-support debootstrap qemu qemu-user-static
  2. Create an empty directory where the chroot will be installed
    # mkdir -p /chroot/oneiric_armel
  3. Now we bootstrap the chroot
    # debootstrap --arch=armel --foreign oneiric /chroot/oneiric_armel http://ports.ubuntu.com/
    This will take time depending on your network connection and drive speed, get yourself a sandwich or catch up on some email.
  4.  
  5. Since we passed the --foreign option to debootstrap the .deb files have been downloaded and unpacked, we are yet to configure the system and finalize the chroot installation. Before we can do anything we need to copy over the qemu binary into the chroot so that we can run ARM executables on the host system using emulation.
    # cp /usr/bin/qemu-arm-static /chroot/oneiric_armel/usr/bin/
    Now we are ready to configure and finalize the base system.
  6.  
  7. To configure the base system, first we need to chroot into and then execute the second stage of debootstrap.
    # chroot /chroot/oneiric_armel/
    /debootstrap/debootstrap --second-stage
    exit
  8. Now we have configured and working base system, we need to create a valid apt source list. The contents of /chroot/oneiric_armel/etc/apt/sources.list should resemble something like this.
    deb http://ports.ubuntu.com/ oneiric main restricted universe multiverse
    deb-src http://ports.ubuntu.com/ oneiric main restricted universe multiverse

With the chroot base system now setup one can use schroot/dchroot to chroot into the base system and install any other packages like a regular chroot. If you want to debootstrap to install a chroot to build packages one needs to just pass the --variant=buildd option to debootstrap in step 3.


[1] http://wiki.debian.org/EmDebian/CrossDebootstrap

Labels: , , , ,


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?