Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate any or all of a cross-compilation toolchain, a root filesystem, a kernel image and a bootloader image. Buildroot is useful mainly for people working with small or embedded systems, using various CPU architectures (x86, ARM, MIPS, PowerPC, etc.) : it automates the building process of your embedded system and eases the cross-compilation process.
The major Buildroot features are:
- Can handle everything in your embedded system development project: cross-compiling toolchain, root filesystem generation, kernel image compilation and bootloader compilation. Buildroot is also sufficiently flexible that it can also be used for only one or several of these steps.
- Is very easy to set up, thanks to its menuconfig, gconfig and xconfig configuration interfaces, familiar to all embedded Linux developers. Building a basic embedded Linux system with Buildroot typically takes 15-30 minutes.
- Supports several hundreds of packages for userspace applications and libraries: X.org stack, Gtk2, Qt, DirectFB, SDL, GStreamer and a large number of network-related and system-related utilities and libraries are supported.
- Supports multiple filesystem types for the root filesystem image: JFFS2, UBIFS, tarballs, romfs, cramfs, squashfs and more.
- Can generate an uClibc cross-compilation toolchain, or re-use your existing glibc, eglibc or uClibc cross-compilation toolchain
- Has a simple structure that makes it easy to understand and extend. It relies only on the well-known Makefile language.
1. ubuntu 系统下准备编译环境,安装编译所需软件包
$ sudo apt-get install build-essential libncurses5-dev bison flex texinfo zlib1g-dev gettext libssl-dev autoconf
buildroot 用 wget 下载软件包源码,因此需要安装 wget
$ sudo apt-get install wget
Ubuntu 默认的 shell 是 dash,它跟 buildroot 的脚本有些不兼容。用下面的命令切换到 bash
$ sudo dpkg-reconfigure dash
2. 下载 buildroot-2012.02,放在 HOME 目录
$ cd $ wget http://buildroot.net/downloads/buildroot-2012.02.tar.bz2
$ tar jxf buildroot-2012.02.tar.bz2
3. 配置 buildroot
buildroot 采用了和 Linux 内核一样的配置工具,使用非常方便。
$ make menuconfig
to save the build time, please use the external toolchain
Toolchain -> Toolchain type (External toolchain) -> Toolchain (Sourcery CodeBench ARM 2011.03)
4. 编译 buildroot。这可能会花几个小时 这可能会花几个小时,取决于你的 Internet 带宽以及 CPU 性能
$ make
编译好的软件包会放在 output/target 目录下,这个目录拥有根文件系统的目录结构。
5.最后生成的根文件系统在 /output/image 目录下
如果想要制作在目标平台运行的本机编译(Native Compile)工具链,则在 make menuconfig 时打开下面两个选项:
1. Build options 子菜单下的 development files in target filesystem
2. Package Selection for the target 子菜单下的 native toolchain in the target filesystem
补充:
1. autoconf, automake 等软件包依赖于 microperl 软件包。在编译 microperl 时可能会遇到找不到 m4 的错误,这时只须执行 make host-m4 即可产生 buildroot_dir/output/host/usr/bin/m4, m4 ,然后再执行 make, 中断的编译将继续进行。
2. 编译某些软件包需要 pkg-config for host config host(在编译平台上运行而非在目标平台上运行)
$ make host-pkgconfig
可编译产生 buil buildroot_dir/output/host/usr/bin/pkg-config