Buildroot Raspberry Pi 4

Raspberry Pi 4 differs significantly from prior version - the processor architecture is different, the bootloader structure is different, the board layout is different (including the PCI Express availability leading to the hack described prior). This means the tooling used to support it need to evolve as well - which is a good opportunity to review and document how it works in the first place.

During my previous experiments with Raspberry Pi (including clusterinng, embedded control, kiosks, etc), I've used Buildroot embedded system heavily. Many advantages include being able to prepare a reproducible SD-card image, which includes all the desired applications, their configuration files, etc - while remaining nimble, and without any unnecessary moving pieces.

As a result, Buildroot images start-up faster, provide solid ground for tweaking, and are less likely to suffer from lost work due to data corruption or forgotten changes. Unfortunately, at the time of this writing, Raspberry Pi 4 is not supported by the upstream version of buildroot - the current changes are forked on my own git repository, and made available for merging.

32bit vs 64bit

The 64bit support on Raspberry Pi 4 is not ready yet - most notably, the SD/MMC support fails over with an error. That said, the buildroot changes were made in such a way as to retain 64bit support - if booted with root on a USB media, or on an initial ramdisk, the resulting infrastructure for building a 64bit userland works well, and the userland is mostly usable.


There are two ways to look at the task ahead - what needs to be done, and where it needs to be done. It's helpful to think about both approaches at once, when reviewing the changes:


What needs to be done?

  • Kernel Version: Moved from: 5eeff139ea9135db6e01a58ef613338f1d0899d8 to 246113692edbef9a438b31ab2dd0172a30ed5eb2
  • Kernel Config: Moved from: bcm2709_defconfig to bcm2711_defconfig
  • Kernel Device Table: Moved from: bcm2710-rpi-3-b to bcm2711-rpi-4-b
  • Bootloader: Extensive changes - different filenames, and different source versions



Where it needs to be done?

  • configs/raspberrypi4_defconfig - this new file defines the necessary settings for building for the new platform
  • board/raspberrypi4 - this new directory (actually a symlink) enabled building for a different variant of Raspberry Pi
  • board/raspberrypi4/genimage-raspberrypi4.cfg - this new file specifies the layout of the SDcard
  • package/rpi-firmware - changes to the package definition allows the configuration file to specify whether the Raspberry Pi 1-3 bootloader, or Raspberry Pi 4 bootloader is to be installed.


configs/raspberrypi4_defconfig - the Buildroot Configuration

This is the top-most configuration change - it ties together all subsequent modifications:

	--- configs/raspberrypi3_defconfig      2019-06-27 01:13:14.927043502 -0400
+++ configs/raspberrypi4_defconfig      2019-07-15 14:06:17.433071215 -0400
@@ -11,17 +11,20 @@
-BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,5eeff139ea9135db6e01a58ef613338f1d0899d8)/linux-5eeff139ea9135db6e01a58ef613338f1d0899d8.tar.gz"
+BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,246113692edbef9a438b31ab2dd0172a30ed5eb2)/linux-246113692edbef9a438b31ab2dd0172a30ed5eb2.tar.gz"
 # Build the DTB from the kernel sources
-BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
 # Required tools to create the SD image
@@ -32,6 +35,6 @@
 # BR2_TARGET_ROOTFS_TAR is not set