Projects / Embedded Linux image / Wrap up
Wrap up
Keep going
- Smaller. Turn off BusyBox applets and packages until
rootfsis under 10 MB. Record each saving. - Faster. Measure the time from QEMU start to the login prompt. What takes the longest? Which start scripts can you drop?
- A service. Make
knaxus-hellorun at boot from a start script and write its output to the log. - Git. Put
/work/knaxus-osunder git. A collaborator should rebuild your image with only Buildroot and your repo. - A real board. Buildroot has defconfigs for the BeagleBone and many others. The same project layout works with a different board file.
What this version leaves out, and what a real engine does
- We boot in an emulator. A real board needs a bootloader such as U-Boot, a device tree for its hardware, and drivers for its chips.
- Our image has a writable root filesystem and no way to update it. Real products use a read-only root and an update system with two copies, so a failed update does not leave a dead device. Tools such as RAUC, SWUpdate and Mender exist for this.
- We did no security hardening. A product removes shells it does not need, drops the root password, signs its images and checks the signature at boot.
- Buildroot rebuilds everything on a big change. Another popular tool, Yocto, trades a steeper learning curve for finer control over many product variants and a package-feed model.
- Our start scripts are BusyBox init scripts. Larger systems often use systemd. Buildroot can build it, with a bigger image.
Check yourself
Answer each question in your head first, then open it to check.
What are the two files you need for a minimal bootable Linux system, and what does each hold?
A kernel image and a root filesystem image. The kernel talks to the hardware and starts the first program. The root filesystem holds that program, the commands, the libraries and the config files.In Step 2.2 a change of hostname rebuilt in about a minute. Why did it not take an hour?
Buildroot tracks what each part depends on. A hostname setting only affects the files in the root filesystem, so it rebuilt that and repacked the image. It did not touch the compiler or the kernel.What does a root filesystem overlay do, and what did the permissions in Step 2.4 teach you about it?
It is a folder that looks like the root of the system, and Buildroot copies it over the image at the end. It keeps the permissions of your files, so a script that is not executable stays that way in the image.Name the links in the boot chain from QEMU to the login prompt. What would you check if the kernel started but no start script ran?
QEMU loads the kernel, the kernel mounts the root filesystem, runs init, init reads/etc/inittaband runs theSscripts, and a login prompt starts. If no start script ran, check/etc/inittab, whether the scripts are executable, and their names in/etc/init.d.Why did Step 4.4 need the original defconfig name, and what was the sign that something was wrong?
The script that createsstart-qemu.shfinds the QEMU command line by looking up the defconfig name. A new name matches nothing. The build still ends without an error, but the boot script is missing.Teach it back: explain to a teammate why we keep Buildroot untouched and our own work in an external tree.
Upstream stays easy to update, and the files that are ours are small and fit in git. Anyone can rebuild the image from a clean Buildroot plus our folder, with nothing hidden in a generated folder.