0% found this document useful (0 votes)
26 views

Building Custom Linux For Raspberry Pi Using Buildroot

This document discusses using Buildroot to build a custom Linux distribution for the Raspberry Pi. Buildroot automates the process of compiling a root filesystem with only necessary packages. The author configures Buildroot for the Raspberry Pi, sets a custom welcome message and root password. They then build the root filesystem image, flash it to an SD card and boot the custom Linux on the Raspberry Pi. SSH is also enabled to allow remote login. Buildroot provides a simple way to customize an embedded Linux build for specific hardware needs.

Uploaded by

Eriton
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Building Custom Linux For Raspberry Pi Using Buildroot

This document discusses using Buildroot to build a custom Linux distribution for the Raspberry Pi. Buildroot automates the process of compiling a root filesystem with only necessary packages. The author configures Buildroot for the Raspberry Pi, sets a custom welcome message and root password. They then build the root filesystem image, flash it to an SD card and boot the custom Linux on the Raspberry Pi. SSH is also enabled to allow remote login. Buildroot provides a simple way to customize an embedded Linux build for specific hardware needs.

Uploaded by

Eriton
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Building custom Linux for

Raspberry Pi using Buildroot

Photo by Louis Reed on Unsplash


Last Valentine’s Day you gifted your girlfriend a project you were working on ,
an internet connected speaker, which enabled you to send love songs to your
sweetheart whenever you felt like dedicating a song . She loved it so much that
she showed it to all her friends and they told their friends and somehow the
word got around and an internet magazine picked up the story and you and
your project was all over the internet ! Amidst all this popularity you saw that
there were many people who were ready to spend their money to buy your
speaker , a light bulb went on in your head and you decided to start a company
and start making these speakers .
When you were prototyping you just used Raspbian/Raspberry Pi OS and used
lots of “apt get install” commands to install the packages needed to make your
project work . You realize now that Raspbian has lot of unnecessary packages
which are not required for your project and also some packages which are
missing which are required for your project , you now wish if only there was a

Building custom Linux for Raspberry Pi using Buildroot 1


way you could build a Linux firmware with only the necessary packages which
you could then flash on an SD card to make it all work seamlessly . Hold onto
your seat! for Buildroot helps you do just that .
Buildroot is an automated build system which takes a set of requirements —
the list of packages to include, kernel configuration, etc. — and creates a self-
contained root filesystem , together with a freshly built kernel , boot loader,
firmware and config files ready to be placed onto the /boot partition of the SD
card.
So let’s not waste time and let’s get started cooking our own flavor of Linux.
Before we start we need to satisfy some prerequisites, according to
the Buildroot manual , Buildroot requires certain packages to be installed before
starting the build. Lets install them using Ubuntu’s package manager

sudo apt install sed make binutils gcc g++ bash patch \gzip
bzip2 perl tar cpio python unzip rsync wget libncurses-dev

Now that we have satisfied all the prerequisites lets download the latest stable
release of Buildroot .

mkdir -p $HOME/buildroot
cd $HOME/buildroot
wget https://buildroot.org/downloads/buildroot-2020.02.2.ta
r.gz
tar xvzf buildroot-2020.02.2.tar.gz
cd buildroot-2020.02.2

Buildroot is a generic build system hence in order to build Linux for Raspberry
Pi we need to configure appropriately . In order to configure buildroot for our
board we start the configuration utility by entering make menuconfig .

Building custom Linux for Raspberry Pi using Buildroot 2


The configuration menu is nicely arranged in submenus which allow you to
configure the buildroot for your target architecture . You can go through each
submenu and its options to find out more about what each option does . Lucky
for us Buildroot already includes config files for some popular boards , these
default config files do all the basic configuration for us . To get a list of default
config files available enter make list-defconfigs :

Building custom Linux for Raspberry Pi using Buildroot 3


You can see that Buildroot includes defconfig files for all the Raspberry pi
boards released until now along with a bunch of other boards . To apply
configuration settings for a board just type make <defconfig name> , for example to
apply default settings for Raspberry Pi 1 you can type,

make raspberrypi_defconfig

Now that you have applied the settings , you can actually start building but just
for the sake of customization lets set a custom welcome message and also set
a root password . Enter make menuconfig and then choose System
Configuration submenu and then select System Banner option and set it to

whatever message you want , since we are building the firmware for our
hypothetical IOT speaker let’s set the welcome message as “Welcome to My
Awesome Speaker” . Now if you look at a few options below , you can see an
option to set root password, set it to the password of your choice .

setting System banner and Root password

We are now done with our customization - exit the configuration and choose
the “save” option as you leave . Initiate a full build of the system by executing :

make all

Building custom Linux for Raspberry Pi using Buildroot 4


Buildroot now starts downloading the packages and starts compiling one by
one , it will probably take around 2–3 hours depending on your host system’s
processing power to complete the build.

Once the build is complete , your system image is generated


under output/images folder with the name “sdcard.img” , now choose your
favorite image flashing software or the dd command to flash the sdcard image
to sdcard . Once the firmware is flashed insert the SDcard into your Pi and
connect the ground, Tx and Rx of USB to Serial cable to the ground (Pin6),
Rx(Pin 10) and Tx(Pin 8) of Raspberry Pi , as shown below .

Connect the USB end of the USB to Serial cable to your computer and open the
serial port using a serial terminal software such as Gtkterm with baud rate set
to 115200 . Power up the system and you should see the custom welcome

Building custom Linux for Raspberry Pi using Buildroot 5


message you set in the previous step , enter the username as “root” and the
root password you had set previously and Voilà! you just logged into your own
custom built Linux.

Serial log showing custom welcome message

Won’t it be cool if we can just log in using SSH instead of using those clunky
serial cables? lets include a SSH software in our custom Linux. Buildroot
includes more than 3000 packages which you can choose to include in your
Linux image, the available packages are listed under “ package/ ” folder of
buildroot . In order to have SSH access to our device , we shall enable
Dropbear, a small SSH server which will let us log in remotely .

Go back to your host computer’s terminal window and enter make menuconfig ,
choose Target packages submenu and enable dropbear under Networking
applications — exit and save your configuration on your way out—
enter make command to start compilation .

Building custom Linux for Raspberry Pi using Buildroot 6


Once the compilation is complete , flash the newly compiled sdcard image —
insert the sdcard to your Pi and connect the Ethernet cable . Open a terminal
window on your host computer and enter :

ssh root@<your Raspberry_Pi's IP address>

You should now have access to your device’s terminal via SSH.

Summary:
In this article you learnt how to build a custom Linux for Raspberry Pi using
Buildroot , in this brief introduction you changed the default System welcome
message and also enabled a software package which enabled you to login
remotely into your system using SSH . I hope this blog helped you to gain some
insight into Buildroot below are some more resources for further reading:
Bootlin’s Buildroot practical lab manual: This training document provides an
hands-on approach for learning Buildroot .
Buildroot User manual : Official user manual for Buildroot .
Happy Tinkering!

Building custom Linux for Raspberry Pi using Buildroot 7

You might also like