Barebox and the bootloader specification – Sasha Hauer (Pengutronix)

In current ARM bootloaders, you have bootloader scripts to find the kernel and boot it. However, these scripts are completely different for different boards. Ubuntu and other distros for instance has completely different boot scripts for different boards. There is no generic support for all boards, like is the case for kernel and rootfs. It also makes it impossible to update the kernel in a generic way, because different boot scripts expect different names for instance. And it also makes it difficult to have multiple distros on a single system.

To fill this gap, there should be a single boot loader specification that tells bootloaders and distros how they should interact with each other. In fact, this does exist for PC in the BootLoaderSpec on Although it is meant for PC, we can use it for ARM as well.

On PC, BootLoaderSpec uses a partition type or GUID to identify the boot partition that contains the boot information. Every boot entry has a config file (<bootpartition>/loader/entries/*.conf). This file is in a specific simple format contains a title, version (which can be used to autoboot latest), machine-id (same as /etc/machine-id), boot options, kernel, initrd, devicetree. The latter three must always be on the same partition. It is recommended that this partition is FAT, and certainly something that the bootloader can write.

If you have a kernel that can boot on multiple machines with different device trees, how do you specify that? In that case, you’re expected to rely on the device tree that the firmware provides you, i.e. compiled into the bootloader or stored in the bootloader environment or in an EEPROM accessed by the bootloader. also provides a kernel-install script that adds conf files based on a kernel/initrd/devicetree you give on the command line. The same script can also run on a host system and update an SD card instead of /boot.

Gummiboot is a UEFI boot manager that implements the BootLoaderSpec. There is also a patch for grub2. Not yet for other bootloaders.

What is missing at the moment in the spec is a way to specify or update the default, so that is determined by the bootloader itself (e.g. latest version). For instance, grub2 has two files: default and once, which point to the conf files from which you should boot. The spec also doesn’t talk about mtd partitions, so on mtd you can’t find the boot partition.

Since there is time left, Sasha continues with explaining some (new) features of barebox.

Barebox support reading device tree. The device tree is compiled into barebox and used to probe its devices. The same device tree is passed to the kernel. It works with i.MX, Tegra and SoCFPGA. This of course requires stability in the bindings, which up to know was more or less guaranteed by the kernel but some people would like to let it go. Of course, that makes updating the device tree impossible without overwriting the bootloader, but you can still supply an external device tree e.g. as per BootLoaderSpec.

Barebox now has multi-image support, i.e. the same config supports multiple boards and several images are produced.

‘detect’ unifies different usb/mmc/sata detection command, which allows you to scan for all devices in a unified way. detect -a scans all device types. mount -a scans all devices and mounts all partitions that are found.

‘magicvar’ shows the variables that have special meaning, including help text. E.g. ethaddr. This is especially useful when you’ve patched barebox.

To run the same bootloader on different board variants, you need to adapt the prebootloader code (that sets memory timings) and based on whatever info you can get select the right timings and the right device tree. This is for instance the case on beaglebone white/black.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s