Buildroot is a tools for building a complex Linux system for an embedded device, using cross-compilation. For this purpose, Buildroot is able to generete:
a cross-compilation tooltain
a root filesystem ('/' symbol)
a linux kernel
a bootloader (e.g., u-boot)
Buildroot is designed to run on a Linux machine. Some tools might needed from the host system. Every 3 months
a new release will be published.
Buildroot Quick Start
Note: you can and should build everything as a normal user! No need for root authority.
First of all, using configuration tool to create configuration file before starting Buildroot building process. Configuration tools reads in the Config.in file and generates a .config file, which contains entire configuration and will be read by the top-level Makefile.
Config.in -------> make menuconfig -------> .config -------> top-level Makefile
Second, using make command to start building process.
make -------> output/
|__ images (stores kernel, bootloader, and root fs images)
|__ build (e.g., compiled packages for the target)
|__ host (contains tools built for the host and the sysroot of target | toolchains)
|__ staging (symlink points to sysroot inside the host directory)
|__ target (contains almost the complete root filesystem for the target except /dev directory, because Buildroot does not run as root)
General produces after calling make:
download source files (as required)
configure, build, and install the cross-compilation toolchain, or simply import an external toolchain
configure, build, and install selected target packages (chosen in .config file?)
build a kernel image if selected
build a bootloader image if selected
create the root filesystem in selected format
Cross-compilation toolchain: runs on host sytem but generates code for target system. It consists of 3 components: a compiler (e.g., gcc), a assembler/linker (e.g., binutils), and a standard C library (e.g., GNU Libc (glibc) or uClibc-ng).
Crosstool-NG
Init System: init program is the first userspace program started by the kernel, BusyBox init is sufficient for most embedded systems. systemd can be used for more complex situations.
what is defconfig, kconfig, and .config files in linux system?
when .config file is being generated, kernel build system goes through all Kconfig files (from all subdirs) and checks all the options in those Kconfig files:
if option is mentioned in defconfig, build system puts that option into .config file with value chosen in defconfig
if option is not mentioned in defconfig, build system puts that option into .config file with the default value, specified in corresponding Kconfig file.
Rebuild a package: to rebuild a single package from scrath is to remove its build directory in output/build.
How to use the existing configuration file for module building?
Busybox, BR2_PACKAGE_BUSYBOX_CONFIG. Using command make busybox-menuconfig to open the BusyBox configuratioin editor.
uClibc, BR2_UCLIBC_CONFIG. Using command make uclibc-menuconfig to open the uClibc configuration editor.
Linux kernel, BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG. Using command make linux-menuconfig to open the the Linux configuration editor.
Barebox, is a derivative of U-Boot. BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG. Using command make barebox-menuconfig to open the barebox configuration editor.
U-Boot, BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG. Using command make uboot-menuconfig to open the U-boot configuration editor.
Make tips
make clean: Explicit cleaning is required when any of the architecture or toolchain configuration options are changed. To delete all build products (including build directories, host, staging and target trees, the images and the toolchain).
make distclean: delete all build products as well as the configuration (resetting Buildroot to a new target).
make clean all: achieved a full rebuild.
make <package>-dirclean: removes the package's build directory in output/build. This is necessary, when you just want to rebuild a single package.
make <package>-rebuild: restarts the compilation and installation of the package, but not from scratch: it basically re-executes make and make install inside the package, so it will only rebuild the files that changed.
Building out-of-tree
When using out-of-tree builds, the Buildroot .config and temporary files are also stored in the output directory. This means that you can safely run multiple builds in parallel using the same source tree as long as they use unique output directories.
make O=/tmp/build -C path/to/buildroot
Note: for ease of use, Buildroot generates a Makefile wrapper in the output directory - so after the first run, you no longer need to pass O=<...> and -C <...>, simply run (in the output directory):
make <target>
Details about packages
make show-info: produces a JSON blurb that describes the set of enabled packages in the current configuration, together with their dependencies, licenses and other metadata.
make pkg-stats: produces details about packages as HTML and JSON output. Amongst other things, these details include whether known CVEs affect the packages in your current configuration. It also shows if there is a newer upstream version for those packages.
Graphing the dependencies between packages
To enable this feature, you need to install the graphviz package on your host system.
make graph-depends: generated graph is stored in output/graph/graph-depends.pdf
make <pkg>-graph-depends: generated graph is stored in output/graph/-graph-depends.pdf
Graphing the build duration
To enable this feature, you need to install python-matplotlib and python-numpy on your host system.
make graph-build: generate a set of files in output/graphs.
Graphing the filesystem size contribution of packages
make graph-size
Developer guide
build out-of-tree: make imx6ulevk_defconfig O=/tmp/imx6_build, this command generates a .config file for imx6ulevk board and a wrapper for it in our customized directory /tmp/imx6_build. We can now go to /tmp/imx6_build directory and run make there or make menuconfig to change the configuration file.
Buildroot Learning
About Buildroot
Buildroot is a tools for building a complex Linux system for an embedded device, using cross-compilation. For this purpose, Buildroot is able to generete:
Buildroot is designed to run on a Linux machine. Some tools might needed from the host system. Every 3 months
a new release will be published.
Buildroot Quick Start
Note: you can and should build everything as a normal user! No need for root authority.
First of all, using configuration tool to create configuration file before starting Buildroot building process. Configuration tools reads in the Config.in file and generates a .config file, which contains entire configuration and will be read by the top-level Makefile.
Second, using make command to start building process.
General produces after calling make:
Cross-compilation toolchain: runs on host sytem but generates code for target system. It consists of 3 components: a compiler (e.g., gcc), a assembler/linker (e.g., binutils), and a standard C library (e.g., GNU Libc (glibc) or uClibc-ng).
Crosstool-NG
Init System: init program is the first userspace program started by the kernel, BusyBox init is sufficient for most embedded systems. systemd can be used for more complex situations.
what is defconfig, kconfig, and .config files in linux system?
when .config file is being generated, kernel build system goes through all Kconfig files (from all subdirs) and checks all the options in those Kconfig files:
Rebuild a package: to rebuild a single package from scrath is to remove its build directory in output/build.
How to use the existing configuration file for module building?
make busybox-menuconfig
to open the BusyBox configuratioin editor.make uclibc-menuconfig
to open the uClibc configuration editor.make linux-menuconfig
to open the the Linux configuration editor.make barebox-menuconfig
to open the barebox configuration editor.make uboot-menuconfig
to open the U-boot configuration editor.Make tips
make clean
: Explicit cleaning is required when any of the architecture or toolchain configuration options are changed. To delete all build products (including build directories, host, staging and target trees, the images and the toolchain).make distclean
: delete all build products as well as the configuration (resetting Buildroot to a new target).make clean all
: achieved a full rebuild.make <package>-dirclean
: removes the package's build directory in output/build. This is necessary, when you just want to rebuild a single package.make <package>-rebuild
: restarts the compilation and installation of the package, but not from scratch: it basically re-executes make and make install inside the package, so it will only rebuild the files that changed.Building out-of-tree
When using out-of-tree builds, the Buildroot .config and temporary files are also stored in the output directory. This means that you can safely run multiple builds in parallel using the same source tree as long as they use unique output directories.
make O=/tmp/build -C path/to/buildroot
Note: for ease of use, Buildroot generates a Makefile wrapper in the output directory - so after the first run, you no longer need to pass O=<...> and -C <...>, simply run (in the output directory):
make <target>
Details about packages
make show-info
: produces a JSON blurb that describes the set of enabled packages in the current configuration, together with their dependencies, licenses and other metadata.make pkg-stats
: produces details about packages as HTML and JSON output. Amongst other things, these details include whether known CVEs affect the packages in your current configuration. It also shows if there is a newer upstream version for those packages.Graphing the dependencies between packages
To enable this feature, you need to install the graphviz package on your host system.
make graph-depends
: generated graph is stored in output/graph/graph-depends.pdfmake <pkg>-graph-depends
: generated graph is stored in output/graph/-graph-depends.pdfGraphing the build duration
To enable this feature, you need to install python-matplotlib and python-numpy on your host system.
make graph-build
: generate a set of files in output/graphs.Graphing the filesystem size contribution of packages
make graph-size
Developer guide
build out-of-tree:
make imx6ulevk_defconfig O=/tmp/imx6_build
, this command generates a .config file for imx6ulevk board and a wrapper for it in our customized directory /tmp/imx6_build. We can now go to /tmp/imx6_build directory and runmake
there ormake menuconfig
to change the configuration file.