Step-by-step Buildroot/Busybox Root File System
UNDER CONSTRUCTION -- ACTIVE EDITING, PLEASE DON'T MAKE CHANGES
This tutorial is for Developers. It is written to work with the odroidu2-ubuntu or odroidu2-debian SD-Card images [is this specific enough?]
It is not for Android developers.
Contents
Introduction
Did you know you can easily make a very small custom-built Linux system? The key is to use the famous "Buildroot" package. This tutorial presents an example to get you started.
You can add additional packages as you like. Many products have been built using this technique with busybox playing the central role.
Prerequisites
Overview
We are going to:
Host Setup
Make sure you have the neccessary programs installed
# update the list of available packages # as root: apt-get update # We need the basics to allow us to build packages on the host, like make, gcc and so on apt-get -y install build-essential bison flex gettext
Download Example Files
You can use your browser, or use web get to get the example files tarball.
# Go to some convenient folder, home if you like cd ~ # Get the example files wget http://odroid.us/odroid/users/osterluk/buildroot-example/buildroot-example.tgz wget http://odroid.us/odroid/users/osterluk/buildroot-example/buildroot-example.tgz.md5sum md5sum -c buildroot-example.tgz.md5sum # Assuming the md5sum is correct, continue tar -xvf buildroot-example.tgz cd buildroot-example
Here are the files we now have:
Expand buildroot and Configure it
In the buildroot-example directory
# expand the tarball tar -xvjf buildroot-2012.11.tar.bz2 # Add our configuration cp odroidu2_just_busybox_defconfig buildroot-2012.11/configs/ # move to the buildroot top directory. This is where you drive buildroot from cd buildroot-2012.11 # and select our configuration make odroidu2_just_busybox_defconfig
Some Toolchain Trivia
You can skip this section, and come back to it later. The topic of toolchains can be confusing.
This example if configured to use an external, downloaded toolchain -- a specific one packaged by CodeSourcery. You don't have to use this toolchain, it is possible to have buildroot build one from scratch. Seriously, why would you, unless for curiosity's sake. If you want to use a paid version of CodeSourcery, you may do that as well, but you need to modify the buildroot configuration to make it work.
Buildroot installs a "private" copy of the cross-compiler. You can use it too, to build for ARM by including it in the path. The arm cross compiler binary is automatically installed to:
./buildroot-example/buildroot-2012.11/output/host/opt/ext-toolchain/bin/arm-none-linux-gnueabi-gcc
The system libraries and binaries get copied to the root file system we build. These live in an area called the "sysroot" as you may see it in documentation.
./buildroot-example/buildroot-2012.11/output/host/opt/ext-toolchain/bin/arm-none-linux-gnueabi/libc
Build the Root File System
I hope this amazes you! The buildroot guys have done a terrific service to the community. Visit them here: Buildroot
The make could take some time, depending on which packages you already have installed.
make
That's all there is to it.
ls output/build
These are the packages that were downloaded, configured and patched for cross-building (some are host packages, used during the build): busybox-1.20.2 host-ccache-3.1.7 host-fakeroot-1.18.2 host-makedevs-undefined
Write the Root File System to SD-Card
See this tutorial Updating from Root File System Images if you don't know what to do with ./output/images/rootfs.tar.gz
Hint: untar the file to the SD-Card rootfs partition
Write the Boot Partition Contents
If you want to be able to bring up the network once you boot the buildroot root file system, you need a kernel configured with smsc95xx network driver built in. The kernel built for Step-by-step NFS-mounted Root File System will do. You can expand the included tarball nfs-mounting-boot.tgz into the boot partition if you like.
[someone please check these steps] Insert the SD-Card, you may need to mount it. Assuming the mount point on your host is /media/boot, then
As root user:
cd /media/boot # Be real careful here. This deletes all files. Make sure you recognize the contents of the directory as the mounted SD-Card boot partition # and NOT YOUR HOST boot partition. Really. Double check. rm -rf * # expand it tar -cvzf /home/user/buildroot-example/nfs-mounting-boot.tgz sync cd ..
Unmount the boot partition, something like: (where X is the drive letter designation)
umount /dev/sdX1
Boot your odroid
Make sure to unmount the SD-Card and put it back into the odroid SD-Card slot, then power it up.
Next Steps
You can add packages, like openssl, dropbear, or any of hundreds of others by doing 'make menuconfig' in the buildroot-2012.11 directory. It can be an iterative process since you generally need to make dependent libraries before the apps that need them.
You can add applets to busybox by running 'make menuconfig' in the output/build/busybox-1.20.2 directory