Using Buildroot on Nitrogen

Published on September 13, 2010

Archived Notice

This article has been archived and may contain broken links, photos and out-of-date information. If you have any questions, please Contact Us.

And now for something completely different.

In prior posts, we've covered some of the basic steps involved in using Desktop-oriented distributions such as Ubuntu and Debian and the Android hand-held distribution.

For a very lightweight alternative, Buildroot may be a good alternative. Put together by the team that brought us Busybox, Buildroot aims for the lean-and-mean. Toward that end, it even ships with an alternative C library, ucLibc.

The toolkit includes everything you need to create a distribution. It can create a cross-compiler for you, and includes a large package set that encompasses GUI tools such as SDL, DirectFB and Qt. It also includes build scripts for Midori, a Webkit based browser, the MPlayer video player, and the gstreamer multimedia framework.

Enough description, let's get buildin'. The following examples are based on the current latest release, 2010.08.

To begin with, you'll need to download and extract the sources: user@host:~$ wget https://buildroot.uclibc.org/downloads/buildroot-2010.08.tar.bz2 user@host:~$ tar jxvf buildroot-2010.08.tar.bz2 tar: Record size = 8 blocks buildroot-2010.08/ buildroot-2010.08/.defconfig buildroot-2010.08/.gitignore buildroot-2010.08/CHANGES buildroot-2010.08/COPYING ... Then you'll need to tell Buildroot about your target.

user@host:~/buildroot-2010.08$ make menuconfig For a Boundary Devices Nitrogen board, you'll want to select Target Architecture "Arm", Target Architecture Variant "Cortex A8", and Toolchain/GCC compiler Version 4.4.x.

You'll also want to check Target Options/Generic serial port config. If you want a serial console, select /dev/ttymxc0 and leave the baud rate at 115200 to match up with U-Boot.

That's it for a minimal installation. You can now run make and Buildroot will produce a complete filesystem image for you in ~/buildroot-2010.08/output/images/rootfs.ext2.

user@host:~/buildroot-2010.08$ make ...lots of spew and around an hour user@host:~/buildroot-2010.08$ ls -lh output/images/ -rw-r--r-- 1 user user 3.7M 2010-09-13 14:40 rootfs.ext2 A complete, runnable Linux in under 4MB! I told you that Buildroot was lean and mean.

Before going through the process of tailoriing the image, let's walk through the steps needed to boot this image over NFS. To quote from the Buildroot documentation, it won't generate a directly usable filesystem because:

Buildroot doesn't run as root and does not want to run as root.


But we can and will (through sudo of course). The following will create directory ~/buildroot-2010.08/nfs and populate it from ~/buildroot-2010.08/output/images/rootfs.ext2 by mounting it through a loopback device:

user@host:~/buildroot-2010.08$ mkdir -p output/ext2 && sudo mount -o loop,ro output/images/rootfs.ext2 output/ext2 [sudo] password for user: user@host:~/buildroot-2010.08$ mkdir -p nfs && sudo cp -avfr output/ext2/* nfs/ `output/ext2/bin' -> `nfs/bin' `output/ext2/bin/egrep' -> `nfs/bin/egrep' `output/ext2/bin/deluser' -> `nfs/bin/deluser' `output/ext2/bin/sync' -> `nfs/bin/sync' ... user@host:~/buildroot-2010.08$ sudo umount output/ext2/

You'll then need to tell your NFS server about the image. Under Ubuntu Lucid running nfs-kernel-server, you can add a line into /etc/exports:

user@host:~/buildroot-2010.08$ sudo su root@host:~/buildroot-2010.08# cat >> /etc/exports /home/user/buildroot-2010.08/nfs *(rw,no_root_squash,no_subtree_check,no_all_squash,sync) ^D root@host:~/buildroot-2010.08# /etc/init.d/nfs-kernel-server reload && exit * Re-exporting directories for NFS kernel daemon... [ OK ] user@host:~/buildroot-2010.08$

There's one more tweak you'll probably want to include before booting your device: there's an entry in /etc/inittab that doesn't work with a standard Nitrogen compile:

tty3::respawn:/usr/bin/tail -f /var/log/messages Since a Nitrogen doesn't normally have a /dev/tty3, you'll want to yank it.

Finally, to configure the device, you'll need to tell U-Boot to boot over NFS:

U-Boot > set bootargs ip=dhcp rootwait root=/dev/nfs nfsroot=192.168.0.44:/home/user/buildroot-2010.08/nfs console=ttymxc0,115200 U-Boot > set bootcmd 'fatload mmc 0 92000000 uImage && lcdp - && bootm 92000000' U-Boot > saveenv && reset Note that these settings use the default display of 1024x768 on DI0 (HDMI). You may want to copy the video= from your existing bootargs variable.

That's it for now. There's a lot of power in the Buildroot package and we encourage you to explore it.

In future posts we'll discuss how some hardware-specific pieces fit into a Buildroot system, but with little more than this you can create a very thin, very powerful system.