How to build buildroot for AT91
The building process alone takes about 75 minutes on a P4-2.8 GHz. It requires a big amount of free disk space ; at least :
- ~240 MByte of source archives downloaded for Internet
- ~2.8 GByte of compiled packages and tools
Now we mainly use buildroot to generate a cross compiler and a root file system.
To build the binary found in the
BuildRootGet page, you will have to go through the following steps.
Prerequisites
Host build system should be a Linux system with necessary softwares installed. We tested buildroot on Fedora 9/10, Debian GNU/Linux 4.0r5 and Ubuntu 8.10.
List of required softwares on the host machine:
- GNU C/C++
- GNU make
- wget
- sed
- flex
- bison
- m4
- patch
- gettext
- libtool
- texinfo
- autoconf
- automake
- ncurses library (development install)
- zlib library (development install)
- libacl library (development install)
- lzo2 library (development install)
- glib library (development install) - if some packages selected
development install means you need to install package for development as well:
- ncurses ncurses-devel
- zlib zlib-devel
- libacl libacl-devel
- lzo lzo-devel

using
yum install or
apt-get install may require you have the
root 's privilege or being in a correct sudoers group.
For example on Fedora
You can check
1~12 by
xxx --version, and
13~16 by
rpm -q xxx.
For example:
$ rpm -q lzo
lzo-2.02-2.fc6
To install lzo packages under
Fedora, you could use:
# yum install lzo lzo-devel

Some old distributions can only install lzo-1.xx by yum, so you need to download a lzo2 package by youself from
http://www.oberhumer.com/opensource/lzo/download/ and install it by hand. For lzo2, there should be a lib file
liblzo2.so in
/usr/lib/, and a folder
lzo/ in
/usr/include/.
For example on Ubuntu
You can check
1~12 by
xxx --version, and
13~16 by
dpkg -l "*xxx*".
For example:
$ dpkg -l "*lzo*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=================-======================-============================================
un liblzo-dev <none> (no description available)
ii liblzo2-2 2.03-1 data compression library
ii liblzo2-dev 2.03-1 data compression library (development files)

here is one install command for development environment on
Ubuntu :
# sudo apt-get install make flex bison m4 ncurses-dev gettext texi2html texinfo zlib1g zlib1g-dev liblzo2-2 liblzo2-dev libacl1 libacl1-dev libglib2.0-dev autoconf automake libtool
Get buildroot
This version is based on buildroot's trunk version
23434 with some modifications.
- You can check out from the standard buildroot svn repository:
svn co -r 23434 svn://uclibc.org/trunk/buildroot
Then apply the
buildroot-v23434.patch. Find it in this page:
BuildRootGet.
$ cd buildroot
$ patch -p1 < ../buildroot-v23434.patch
$ chmod u+x scripts/wget.sh
Build buildroot
In buildroot's top directory, there is a folder called
local, in which you can see:
$ ls local/AT91/
AT91.config
busybox-1.12.0.config
uclibc-0.9.29.config
The first config file will be copyed to ".config" file , after
make BOARD=AT91 getconfig.
The second config file is for busybox.
The third conifg file is for uClibc.
$ make menuconfig
$ make BOARD=AT91 getconfig
$ make 2>&1 | tee at91sam9.log
The first command will create the initial ".config" file.
The third command will build everything, and log the error messages if there are.
Finally, the root file system image files can be found in buildroot/binaries/AT91/:
$ ls buildroot/binaries/AT91/
rootfs.arm_nofpu.cramfs
rootfs.arm_nofpu.ext2
rootfs.arm_nofpu.jffs2
Customizing Buildroot
Buildroot is an extensible system. We can customize different parts of the system. For example, the generated root filesystem, cross toolchain, busybox, uClibc etc. are all customisable. For detailed information, see
buildroot's official documents.
Customizing the target filesystem
There are a few ways to customize the resulting target filesystem:
- Customize the target filesystem directly, and rebuild the image. The target filesystem is available under project_build_ARCH/root/ where ARCH is the chosen target architecture. You can simply make your changes here, and run make afterwards, which will rebuild the target filesystem image. This method allows to do everything on the target filesystem, but if you decide to completely rebuild your toolchain and tools, these changes will be lost.
- Customize the target filesystem skeleton, available under target/generic/target_skeleton/. You can customize configuration files or other stuff here. However, the full file hierarchy is not yet present, because it's created during the compilation process. So you can't do everything on this target filesystem skeleton, but changes to it remain even if you completely rebuild the cross-compilation toolchain and the tools.
You can also customize the target/generic/device_table.txt file which is used by the tools that generate the target filesystem image to properly set permissions and create device nodes. The target/generic/skel.tar.gz file contains the main directories of a root filesystem and there is no obvious reason for which it should be changed. These main directories are in an tarball inside of inside the skeleton because it contains symlinks that would be broken otherwise.
These customizations are deployed into project_build_ARCH/root/ just before the actual image is made. So simply rebuilding the image by running make should propagate any new changes to the image.
- When configuring the build system, using make menuconfig, you can specify the contents of the /etc/hostname and /etc/issue (the welcome banner) in the PROJECT section
Customizing the Busybox configuration
Busybox is very configurable, and you may want to customize it. You can follow these simple steps to do it. It's not an optimal way, but it's simple and it works.
- Make a first compilation of buildroot with busybox without trying to customize it.
- Invoke make busybox-menuconfig. The nice configuration tool appears and you can customize everything.
- Run the compilation of buildroot again.
Otherwise, you can simply change the
package/busybox/busybox-.config file if you know the options you want to change without using the configuration tool.
Customizing the uClibc configuration
Just like BusyBox, uClibc offers a lot of configuration options. They allow to select various functionalities, depending on your needs and limitations.
The easiest way to modify the configuration of uClibc is to follow these steps :
- Make a first compilation of buildroot without trying to customize uClibc.
- Invoke make uclibc-menuconfig. The nice configuration assistant, similar to the one used in the Linux Kernel or in Buildroot appears. Make your configuration as appropriate.
- Copy the .config file to toolchain/uClibc/uClibc.config or toolchain/uClibc/uClibc.config-locale. The former is used if you haven't selected locale support in Buildroot configuration, and the latter is used if you have selected locale support.
- Run the compilation of Buildroot again
Otherwise, you can simply change
toolchain/uClibc/uClibc.config or
toolchain/uClibc/uClibc.config-locale without running the configuration assistant.
Add your own software to BuildRoot
BuilRoot is basically a big set of makefiles so you will have to follow some steps to insert your own application to the cross-building system. You can take example on files in the
package/dummy directory. Use the official documentation:
Extending Buildroot with more Software to figure out those directives meaning.
Install Modules of Linux Kernel
For customers who want to build some functional components as modules for Linux Kernel, they can do this way:
make INSTALL_MOD_PATH="path string" modules_install
Here the
path string is the absolute path of the uncompressed root file system, for example :
'prefix'/buildroot/project_build_arm/AT91/root/.
Then you just enter the directory of buildroot and
make, only the file system images are updated this time.
--
EricXu - 18 Dec 2008