When one needs to create an embedded Linux system for a given platform, mainly two choices are available: use a pre-built binary distribution such as Debian or Ubuntu, which relies on native compilation, or use a tool that rebuilds from source, through cross-compilation, a small Linux system. Buildroot is a tool that falls into the second category, and provides to embedded Linux developers a very simple utility to automate the process of building their systems.
Buildroot supports many CPU architectures, from the most popular ones such as ARM, x86, PowerPC or MIPS, all the way to more specific ones such as Microblaze, Blackfin or ARC. It includes the ability to build cross-compilation toolchains, a Linux kernel image, bootloader images, and about 1000 userspace packages, for components such as Qt, Gtk, X.org, Gstreamer and many others. Compared to other embedded Linux build systems, Buildroot puts a strong emphasis on simplicity, and as such is being used by a very large number of embedded companies, processor vendors, and hobbyists. For example, Google uses Buildroot to build the embedded Linux system that powers the devices used in the Google Fiber project.
Through this talk, we would like to detail how Buildroot works from an user-level point of view, the features that it provides, how easy it is to extend and understand its internal architecture, and give insights on how to use it for real projects.
See http://lca2014.linux.org.au/schedule/30128/view_talk?day=wednesday
Video available at https://www.youtube.com/watch?v=GP2C00hcHvI.
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Buildroot: building embedded Linux systems made easy! (Linux Conf Australia 2014)
1. Linux Conf Australia 2014
Buildroot: building
embedded Linux
systems made easy!
Thomas Petazzoni
Free Electrons
thomas.petazzoni@free-electrons.com
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 1/29
2. Thomas Petazzoni
CTO and embedded Linux engineer at
Free Electrons
Embedded Linux expertise
Development, consulting and training
Strong open-source focus
Embedded Linux
Developers
Free Electrons
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 2/29
3. Thomas Petazzoni
CTO and embedded Linux engineer at
Free Electrons
Open-source contributor
Contributing the kernel support for
Marvell ARM processors
Major contributor to Buildroot, 1600+
patches contributed
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 2/29
4. Thomas Petazzoni
CTO and embedded Linux engineer at
Free Electrons
Open-source contributor
Living in Toulouse, south west of France
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 2/29
5. Embedded ?
These days, when you say embedded, most people think:
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 3/29
6. Embedded ?
These days, when you say embedded, most people think:
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 3/29
7. Embedded ?
These days, when you say embedded, most people think:
Powerful dual/quad ARM/x86 processor
Several GBs of RAM
Dozens of GBs of storage
Full-featured, general-purpose operating system (Android)
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 3/29
8. Embedded ?
But there are much more embedded systems than just phones and
tablets:
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 4/29
9. Embedded ?
But there are much more embedded systems than just phones and
tablets:
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 4/29
10. Embedded ?
But there are much more embedded systems than just phones and
tablets:
Very application-specific →
need a custom Linux system
Less powerful CPUs,
sometimes specialized CPU
architectures
Less RAM (a few dozen to a
few hundred MBs)
Less storage
Long life-time and
maintenance period
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 4/29
11. Building an embedded Linux system
+ Readily available
- Large, usually 100+ MB
- Not available for all architectures
- Not easy to customize
- Generally require native compilation
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 5/29
12. Building an embedded Linux system
+ Smaller and flexible
- Very hard to handle cross-compilation and dependencies
- Not reproducible
- No benefit from other people’s work
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 5/29
13. Building an embedded Linux system
+ Small and flexible
+ Reproducible, handles cross-compilation and dependencies
+ Available for virtually all architectures
- One tool to learn
- Build time
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 5/29
14. Embedded Linux build system: principle
Building from source → lot of flexibility
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 6/29
15. Embedded Linux build system: principle
Building from source → lot of flexibility
Cross-compilation → leveraging fast build machines
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 6/29
16. Embedded Linux build system: principle
Building from source → lot of flexibility
Cross-compilation → leveraging fast build machines
Recipes for building components → easy
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 6/29
17. Embedded Linux build system: tools
A wide range of solutions: Yocto/OpenEmbedded, PTXdist,
Buildroot, LTIB, OpenBricks, OpenWRT, and more.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 7/29
18. Embedded Linux build system: tools
A wide range of solutions: Yocto/OpenEmbedded, PTXdist,
Buildroot, LTIB, OpenBricks, OpenWRT, and more.
Today, two solutions are emerging as the most popular ones
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 7/29
19. Embedded Linux build system: tools
A wide range of solutions: Yocto/OpenEmbedded, PTXdist,
Buildroot, LTIB, OpenBricks, OpenWRT, and more.
Today, two solutions are emerging as the most popular ones
Yocto/OpenEmbedded
Builds a complete Linux distribution with binary packages.
Powerful, but somewhat complex, and quite steep learning
curve.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 7/29
20. Embedded Linux build system: tools
A wide range of solutions: Yocto/OpenEmbedded, PTXdist,
Buildroot, LTIB, OpenBricks, OpenWRT, and more.
Today, two solutions are emerging as the most popular ones
Yocto/OpenEmbedded
Builds a complete Linux distribution with binary packages.
Powerful, but somewhat complex, and quite steep learning
curve.
Buildroot
Builds a root filesystem image, no binary packages. Much
simpler to use, understand and modify.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 7/29
21. Buildroot at a glance
Can build a toolchain, a rootfs, a kernel, a bootloader
Easy to configure: menuconfig, xconfig, etc.
Fast: builds a simple root filesystem in a few minutes
Easy to understand: written in make, extensive documentation
Small root filesystem, starting at 2 MB
More than 1000 packages for userspace libraries/apps
available
Many architectures supported
Well-known technologies : make and kconfig
Vendor neutral
Active community, regular releases
http://buildroot.org
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 8/29
22. Who’s using Buildroot?
System makers
Google
Barco
Rockwell Collins
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 9/29
23. Who’s using Buildroot?
System makers
Google
Barco
Rockwell Collins
Processor vendors
Analog Devices
Imagination Technologies
Marvell
Atmel
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 9/29
24. Who’s using Buildroot?
System makers
Google
Barco
Rockwell Collins
Processor vendors
Analog Devices
Imagination Technologies
Marvell
Atmel
Many, many hobbyists on
development boards: Rasberry Pi,
BeagleBone Black, etc.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 9/29
25. Getting started
git clone git://git.busybox.net/buildroot
cd buildroot
make menuconfig
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 10/29
26. Buildroot configuration
1. Target architecture
Architecture
ARC, ARM, AArch64, AVR32,
Blackfin, Microblaze, MIPS, NIOS II,
PowerPC, SuperH, SPARC, x86,
x86 64, Xtensa
Specific processor
ABI
Floating point strategy
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
27. Buildroot configuration
1. Target architecture
2. Build options
Download directory
Number of parallel jobs
Use of ccache
Shared or static libraries
etc.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
28. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
Buildroot toolchain
Buildroot builds the toolchain
uClibc, glibc, eglibc
External toolchain
Uses a pre-built toolchain
Profiles for existing popular
toolchains
Linaro, Sourcery CodeBench,
Analog Devices, etc.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
29. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
4. System configuration
Init system to use: Busybox,
Sysvinit, Systemd
/dev management solution: static,
devtmpfs, mdev, udev
Hostname, password, getty
terminal, etc.
Custom post build and post image
scripts
etc.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
30. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
4. System configuration
5. Kernel
Kernel source (stable version, Git
tree, patches)
Kernel configuration
Support for RTAI and Xenomai
real-time extensions
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
31. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
4. System configuration
5. Kernel
6. Target packages
More than 1000 packages
Qt4, Qt5, X.org, Gtk, EFL
GStreamer, ffmpeg
Python, Perl, Ruby, Lua
Samba, OpenSSL, OpenSSH,
dropbear, lighttpd
OpenGL support for various
platforms
And many, many more libraries and
utilities
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
32. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
4. System configuration
5. Kernel
6. Target packages
7. Filesystem images
Major filesystem formats supported
cloop
cpio, for kernel initramfs
cramfs
ext2/3/4
jffs2
romfs
squashfs
tar
ubifs
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
33. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
4. System configuration
5. Kernel
6. Target packages
7. Filesystem images
8. Bootloaders
Grub
Syslinux
U-Boot
Barebox
and more platform-specific
bootloaders: imx-bootlets,
at91bootstrap, etc.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
34. Buildroot configuration
1. Target architecture
2. Build options
3. Toolchain
4. System configuration
5. Kernel
6. Target packages
7. Filesystem images
8. Bootloaders
9. Host utilities
Allows to build some native tools,
useful for development.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 11/29
36. Building and using
To start the build: make
Results in output/images:
rootfs.tar, root filesystem in tar format
rootfs.ubi, root filesystem in UBI format
uImage, Linux kernel image
u-boot.bin, U-Boot bootloader image
Ready to be flashed on your embedded system.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 13/29
37. Exploring the build output
All the output produced by Buildroot is stored in output/
Can be customized using O= for out-of-tree build
output/ contains
output/build, with one sub-directory for the source code of
each component
output/host, which contains all native utilities needed for the
build, including the cross-compiler
output/host/usr/<tuple>/sysroot, which contains all the
headers and libraries built for the target
output/target, which contains almost the target root
filesystem
output/images, the final images
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 14/29
38. Summarized build process
1. Copies the rootfs skeleton to target/
2. Takes care of the cross-compilation toolchain
internal toolchain: Downloads, patches, configures, builds
and installs binutils, gcc, C library and the necessary
dependencies
external toolchain: Copy the necessary bits of the toolchain
into Buildroot output directory.
3. For each selected package, after taking care of its
dependencies: download, extract, patch, configure, build,
install
To target/ for target apps and libs
To host/usr/<tuple>/sysroot for target libs
To host/ for native apps and libs
4. Generate the root filesystem image
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 15/29
39. Real-world example 1
The device is an ARM AT91-based platform with GPS, RFID
readers, GSM modem, Ethernet and USB.
The Buildroot configuration:
CodeSourcery ARM glibc toolchain
Linux kernel
BusyBox for the basic system
Dropbear for SSH access (debugging)
Qt with only QtCore, QtNetwork and QtXml, no GUI
QExtSerialPort
zlib, libxml2, logrotate, pppd, strace, a special RFID library,
popt library
The Qt application
JFFS2 root filesystem
Filesystem size: 11 MB. Could be reduced by using uClibc.
Build time: 10 minutes on a fast build server (quad-core i7,
12 GB of RAM)
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 16/29
40. Real-world example 2
An x86-based system, with an OpenGL application for vehicle
navigation system.
External glibc toolchain generated with crosstool-NG
The Grub bootloader
Linux kernel, of course
BusyBox
A large part of the X.org stack (the server, a few drivers, and
some client libraries), including libdrm, Mesa
The fglrx ATI proprietary OpenGL driver
ALSA utils, ALSA library, V4L library, Flashrom, LM Sensors,
Lua, Dropbear, Ethtool
The OpenGL application and its data
Filesystem size: 95 MB, with 10 MB of application (binary +
data) and 45 MB (!) of fglrx driver.
Build time: 27 minutes on a fast build server (quad-core i7,
12 GB of RAM)
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 17/29
41. Customizing the build
Besides the existing packages, there are multiple ways to customize
the generated root filesystem:
Create custom post-build and/or post-image scripts
Use a root filesystem overlay, recommended to add all your
config files
Add your own packages
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 18/29
42. Adding a new package: Config.in (1/2)
package/libmicrohttpd/Config.in
config BR2_PACKAGE_LIBMICROHTTPD
bool "libmicrohttpd"
depends on BR2_TOOLCHAIN_HAS_THREADS
help
GNU libmicrohttpd is a small C library that makes it easy to
run an HTTP server as part of another application.
http://www.gnu.org/software/libmicrohttpd/
comment "libmicrohttpd needs a toolchain w/ threads"
depends on !BR2_TOOLCHAIN_HAS_THREADS
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 19/29
43. Adding a new package: Config.in (2/2)
package/Config.in
[...]
source "package/libmicrohttpd/Config.in"
[...]
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 20/29
44. Adding a new package: <pkg>.mk
package/libmicrohttpd/libmicrohttpd.mk
LIBMICROHTTPD_VERSION = 0.9.33
LIBMICROHTTPD_SITE = $(BR2_GNU_MIRROR)/libmicrohttpd
LIBMICROHTTPD_LICENSE = LGPLv2.1+
LIBMICROHTTPD_LICENSE_FILES = COPYING
LIBMICROHTTPD_INSTALL_STAGING = YES
LIBMICROHTTPD_CONF_OPT = --disable-spdy
$(eval $(autotools-package))
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 21/29
45. Adding a new package: infrastructures
In order to factorize similar behavior between packages using
the same build mechanism, Buildroot has package
infrastructures
autotools-package for autoconf/automake based packages
cmake-package for CMake based packages
python-package for Python Distutils and Setuptools based
packages
generic-package for non-standard build systems
Coming: infrastructures for Perl and Lua packages
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 22/29
46. Legal infrastructure
License compliance is an important topic for embedded Linux
systems
Needs to keep track of the license and source code of each
component
In Buildroot, licensing informations are attached to each
package
The make legal-info target generates:
A licensing manifest, CSV format
License text for all components
Source code for all components
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 23/29
47. Dependency graphing
make graph-depends
ALL
rpi-firmware busybox linux tvheadendlibcofi toolchain-external rootfs-tardropbear
lighttpd
rpi-userland i2c-tools
host-python
host-expat
host-autoconf
host-automake
host-libtool
host-zlib
host-pkgconf
host-kmod
host-lzop openssldvb-apps
host-m4
zlibhost-lzo
host-fakeroot host-makedevs host-cmake
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 24/29
48. Defconfigs
Pre-defined configurations for popular platforms
They build a minimal system for the platform
make <foobar>_defconfig to load one of them
Some of the configs
RasberryPi
BeagleBone
CubieBoard
PandaBoard
Many Atmel development boards
Several Freescale i.MX6 boards
Many Qemu configurations
and more...
make help for the full list
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 25/29
49. Buildroot, an active project
Releases published
every 3 months
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 26/29
50. Buildroot, an active project
Releases published
every 3 months
Growing number of
contributors: 35-40
different contributors
each month
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 26/29
51. Buildroot, an active project
Releases published
every 3 months
Growing number of
contributors: 35-40
different contributors
each month
Growing activity:
1500-2000
e-mails/month
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 26/29
52. Buildroot, an active project
Releases published
every 3 months
Growing number of
contributors: 35-40
different contributors
each month
Growing activity:
1500-2000
e-mails/month
Growing number of
packages
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 26/29
53. Buildroot, an active project
Releases published
every 3 months
Growing number of
contributors: 35-40
different contributors
each month
Growing activity:
1500-2000
e-mails/month
Growing number of
packages
Bi-yearly physical
meeting
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 26/29
54. Getting support
Documentation:
http://buildroot.org/downloads/manual/manual.html
Mailing list: buildroot@uclibc.org
IRC channel: #buildroot on Freenode
Bug tracker: https://bugs.uclibc.org
Friendly and welcoming community
Companies offering commercial support
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 27/29
55. Conclusion
Nice : uses well-known technologies and languages, kconfig
and make. Active and friendly community.
Simple : only a few hundreds lines of code to understand the
core infrastructure. Easy to get started, and easy to fully
understand the internal mechanisms.
Efficient : very reasonable build times, only what’s necessary
gets built.
Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com 28/29