Using Buildroot for the Raspberry Pi 4
I recently started toying with the idea of using a raspberry pi in one of my future projects. The raspberry pi would essentially function as an embedded device. There is a naive way to achieve this, install raspbian, install libraries, maybe write some code and deploy it. However this doesn’t feel like the proper way to deploy a raspberry pi in an embedded environment. I have a few requirements:
- The system needs to be easily reproducible (and resettable!)
- As much of the system needs to be read-only, for security reasons.
- It doesn’t require any manual interactions with the raspberry pi besides flashing the micro SD card.
My servers run an upgraded version of k3os, and that basically satisfies every requirement. But changing that to run other programs, stripping the k3os-part and making an easily flashable media for the RPI4 seems like too much work.
That is where buildroot comes into play, which is a project that specializes in creating custom bootable linux derivations, with support for the raspberry pi. Creating a basic bootable image for the raspberry pi 4 is as follows:
1. Download buildroot
Downloading buildroot is very simple, I just downloaded the latest stable version from here: https://buildroot.org/download.html
2. Load the raspberry pi 4 preset
Extract the downloaded file into a dedicated directory, and open a terminal in said directory. Then run the following command to change all settings to the defaults for raspberry pi 4.
make raspberrypi4_defconfig
3. Compile the project
Compiling is as simple as running
make all
This can take a while though, on my desktop computer (Ryzen 7 5800X) it took ~30 minutes. My 6 year old laptop that runs some i5 took around 1 and a half hours.
4. Flash the SD-Card
You know how this is done, just use dd
.
And thats it! the minimal setup for buildroot that runs on the raspberry pi 4. Ofcourse you will want to customize it. This can be done using make menuconfig
, which will open a TUI that allows you to change settings or add programs/libraries.
In my case, I needed libcamera; which was easily added in the menuconfig.


Then a simple recompile, and its ready to boot. I connected to my raspberry pi using a USART adapter connected to the RX/TX pins, and everything worked out of the box. I will continue playing with buildroot, and will probably write more about it in my quest to make a video doorbell.