Embedded Linux Conference Europe 2014 Buildroot: a deep dive into the core Thomas Petazzoni Free Electrons thomas.petazzoni@free-electrons.com Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 1/42
Thomas Petazzoni ◮ CTO and Embedded Linux engineer at Free Electrons ◮ Embedded Linux and Android development : kernel and driver development, system integration, boot time and power consumption optimization, consulting, etc. ◮ Embedded Linux, Linux driver development, Android system and Yocto/OpenEmbedded training courses , with materials freely available under a Creative Commons license. ◮ http://free-electrons.com ◮ Contributions ◮ Kernel support for the Marvell Armada ARM SoCs from Marvell ◮ Major contributor to Buildroot , an open-source, simple and fast embedded Linux build system ◮ Living in Toulouse , south west of France Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 2/42
Agenda 1. Quick introduction about Buildroot 2. Source tree and output tree 3. Configuration system 4. From make to the generic package infrastructure 5. Specialized package infrastructures 6. Toolchain support 7. Root filesystem image generation 8. Overall build logic Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 3/42
Buildroot at a glance ◮ An embedded Linux build system , builds from source: ◮ cross-compilation toolchain ◮ root filesystem with many libraries/applications, cross-built ◮ kernel and bootloader images ◮ Fast , simple root filesystem in minutes ◮ Easy to use and understand: kconfig and make ◮ Small root filesystem, default 2 MB ◮ More than 1200 packages available ◮ Generates filesystem images, not a distribution ◮ Vendor neutral ◮ Active community, regular releases ◮ Started in 2001, oldest still maintained build system ◮ http://buildroot.org Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 4/42
Demonstration A demonstration is worth many slides! Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 5/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ linux/ ◮ top-level Makefile , handles the ◮ package/ configuration and general orchestration of the build ◮ fs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ linux/ ◮ top-level Config.in , main/general ◮ package/ options. Includes many other Config.in files ◮ fs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ Config.in.* files defining the ◮ system/ architecture variants (processor ◮ linux/ type, ABI, floating point, etc.) ◮ package/ ◮ Config.in , Config.in.arm , ◮ fs/ Config.in.x86 , ◮ boot/ Config.in.microblaze , etc. ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ packages for generating or using ◮ arch/ toolchains ◮ toolchain/ ◮ toolchain/ virtual package that ◮ system/ depends on either ◮ linux/ toolchain-buildroot or ◮ package/ toolchain-external ◮ toolchain-buildroot/ virtual ◮ fs/ package to build the internal ◮ boot/ toolchain ◮ configs/ ◮ toolchain-external/ package to ◮ board/ handle external toolchains ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ skeleton/ the rootfs skeleton ◮ linux/ ◮ Config.in , options for ◮ package/ system-wide features like init ◮ fs/ system, /dev handling, etc. ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ linux/ ◮ linux.mk , the Linux kernel ◮ package/ package ◮ fs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ all the userspace packages (1200+) ◮ toolchain/ ◮ busybox/ , gcc/ , qt5/ , etc. ◮ system/ ◮ pkg-generic.mk , core package ◮ linux/ infrastructure ◮ package/ ◮ pkg-cmake.mk , ◮ fs/ pkg-autotools.mk , ◮ boot/ pkg-perl.mk , etc. Specialized ◮ configs/ package infrastructures ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ logic to generate filesystem images ◮ linux/ in various formats ◮ package/ ◮ common.mk , common logic ◮ fs/ ◮ cpio/ , ext2/ , squashfs/ , tar/ , ubifs/ , etc. ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ linux/ ◮ bootloader packages ◮ package/ ◮ at91bootstrap3/ , barebox/ , grub/ , syslinux/ , uboot/ , etc. ◮ fs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ default configuration files for ◮ system/ various platforms ◮ linux/ ◮ similar to kernel defconfigs ◮ package/ ◮ atmel_xplained_defconfig , ◮ fs/ beaglebone_defconfig , ◮ boot/ raspberrypi_defconfig , etc. ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ board-specific files (kernel ◮ linux/ configuration files, kernel patches, image flashing scripts, etc.) ◮ package/ ◮ typically go together with a ◮ fs/ defconfig in configs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ linux/ ◮ misc utilities (kconfig code, libtool patches, download helpers, and ◮ package/ more.) ◮ fs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Source tree ◮ Makefile ◮ Config.in ◮ arch/ ◮ toolchain/ ◮ system/ ◮ linux/ ◮ Buildroot documentation ◮ package/ 90 pages PDF document ◮ ◮ fs/ ◮ boot/ ◮ configs/ ◮ board/ ◮ support/ ◮ docs/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 6/42
Output tree ◮ output/ ◮ build/ ◮ host/ ◮ staging/ ◮ target/ ◮ images/ ◮ graphs/ ◮ legal-info/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 7/42
Output tree ◮ Global output directory ◮ output/ ◮ Can be customized for ◮ build/ out-of-tree build by passing ◮ host/ O=<dir> ◮ staging/ ◮ target/ ◮ Variable: O (as passed on the ◮ images/ command line) ◮ graphs/ ◮ Variable: BASE_DIR (as an ◮ legal-info/ absolute path) Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 7/42
Output tree ◮ output/ ◮ Where all source tarballs are ◮ build/ extracted ◮ buildroot-config/ ◮ busybox-1.22.1/ ◮ host-pkgconf-0.8.9/ ◮ Where the build of each ◮ kmod-1.18/ ◮ build-time.log package takes place ◮ host/ ◮ In addition to the package ◮ staging/ sources and object files, stamp ◮ target/ files are created by Buildroot ◮ images/ ◮ graphs/ ◮ Variable: BUILD_DIR ◮ legal-info/ Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com 7/42
Recommend
More recommend