If you are an embedded software developer like me chances are you use embedded Linux for the purpose. It's Open Source, has great tools support and is a great software environment where (almost) everything could be automated through command line interfaces.
Once you decide about operating system used the next step is to choose a build system that would be used for the task of building the software. There are few choices you can select from:
- use pre-built toolchain and rootfs and add your binaries and configuration files (i.e. STLinux for ST-based devices)
- use OpenEmbedded for full-featured buildsystem with packaging system included
- use BuildRoot for simple build system without packaging system included
Today I'm going to tell you about the 3rd option. Buildroot states their view on packaging systems for embedded development this way:
We believe that for most embedded Linux systems, binary packages are not necessary, and potentially harmful. When binary packages are used, it means that the system can be partially upgraded, which creates an enormous number of possible combinations of package versions that should be tested before doing the upgrade on the embedded device. On the other hand, by doing complete system upgrades by upgrading the entire root filesystem image at once, the image deployed to the embedded system is guaranteed to really be the one that has been tested and validated.
After few years with OpenEmbedded and few months with Buildroot I like the simplicity of Buildroot model. Below you can find basic (the most important in my opinion) concepts of Buildroot.
Buildroot uses basic "make" interface and, actually, it's written in Makefile language. It's clearly visible in (sometimes) weird syntax for packages declaration. For configuration Config.in files are used (the same as for Linux kernel configuration). It's quite useful and extensible choice for configuration and building.
Recipes system (usually placed under package/ subdirectory) describes in Makefile+Config.in language rules for fetching / configuring / building / installing. You can build+install selected package by issuing: "make <pkg-name>" - quite simple and elegant solution.
Each build is configured in .config file that could be edited make well-known "make menuconfig" interface:
You could select build switches there as well as list of included packages.
All the output is placed under "output" subdirectory (you can force full clean by deleting this directory):
- build/<pkg-name>/ - working directory for building given package (no "rm_work" there as in OE, build directories are kept after build)
- build/<pkg-name>/.stamp_* - describes build state for given package, you can force given stage by deleting selected files there
- host/ - the toolchain
- target/ - rootfs (filled in fakeroot mode) used for creating resulting images
- images/ - resulting images are placed there (tgz, squashfs, kernel binary and so on)
Basic input directories:
- package/<pkg-name>/<pkg-name>.mk - a recipe for given package (Makefile syntax)
- Config.in - root of configuration files possible options
- dl/ - this directory is not stored in version control system, but holds cached version of downloads. It's placed outside of output directory in order not to download source packages after every clean
- fs/ - recipes for various output image options (tgz, squashfs and so on)
- system/skeleton/ - basic filesystem structure
The buildsystem is very fast and allows very high level of customizations.