Buildroot with Pigeon computers tutorial

This tutorial demonstrates how to build a small custom Linux system for Pigeon computers using Buildroot. Buildroot is a tool that simplifies and automates the creation of a complete Linux system for embedded devices through cross-compilation. It can generate a cross-compilation toolchain, a root filesystem, a Linux kernel image, and a bootloader. Buildroot is designed to be executed on Linux systems. This text includes excerpts from the Buildroot user manual.

Prerequisites

In this tutorial, the Debian distribution is used on the host machine. Before proceeding, make sure all required packages are installed:

sudo apt-get update
sudo apt-get install sed make binutils build-essential gcc g++ bash patch gzip bzip2
sudo apt-get install perl tar cpio python unzip rsync wget bc git
sudo apt-get install ncurses-base ncurses-bin ncurses-dev libncurses5-dev dialog

If you intend to use make xconfig:

sudo apt-get install libqt4-dev qt4-dev-tools

Getting Buildroot

At the time of writing this tutorial, the latest stable version of Buildroot is 2016.05. Buildroot releases occur every three months, specifically in February, May, August, and November. The release numbers follow the format YYYY.MM. Release tarballs can be obtained from buildroot.org/downloads/. Let's begin by downloading Buildroot:

mkdir buildroot
cd buildroot
wget http://buildroot.org/downloads/buildroot-2016.05.tar.bz2
tar xvjf buildroot-2016.05.tar.bz2
cd buildroot-2016.05

Configure Buildroot

The initial step when using Buildroot is to create a configuration. You should build everything as a regular user; there is no need for root privileges to configure and use Buildroot.

Download the Buildroot files for Pigeon computers from our GitHub repository:

wget --no-check-certificate https://raw.githubusercontent.com/kristech/pigeon-rb-buildroot/master/buildroot-2016.05/buildroot-2016.05.tar.bz2
tar jxvf buildroot-2016.05.tar.bz2

Then, for example, run the following command for the Pigeon RB100:

make pigeon_rb100_defconfig

If you want to modify the Buildroot configuration, execute the following command:

make menuconfig

To modify the kernel configuration, execute the following command:

make linux-menuconfig

Build system

To start the build process, simply run:

make

The process may take some time.

Writing the Image to eMMC

The Buildroot output images are located in the output/images/ directory. To write the SD card image to the Pigeon computer's eMMC (where X is the drive letter designation), use the following command:

dd if=output/images/sdcard.img of=/dev/sdX
sync

For more detail see Operating system installation.

Boot your Pigeon

After removing the cable from the USB device slot and power cycling the Pigeon, the kernel will load and mount the root filesystem partition. You should see the following banner:

Welcome to Pigeon RB100
pigeon login: root

The default login credentials are:

  • Username: root
  • Password: kristech

Tips

Read-only root filesystem partition

By default, the root filesystem partition is mounted in read-write mode. To change it to read-only mode, follow these steps:

make menuconfig

After making the change, proceed to power off the device by:

System configuration

  • remount root filesystem read-write during boot

You can also use the rw and ro script files in the Pigeon console to switch between read-write and read-only modes:

# ro
[ 4742.051335] EXT4-fs (mmcblk0p2): re-mounted. Opts: errors=remount-ro,data=ordered
# echo text > test.txt
-sh: can't create test.txt: Read-only file system
# rw
[ 4765.083886] EXT4-fs (mmcblk0p2): re-mounted. Opts: errors=remount-ro,data=ordered
# echo text > test.txt
# ls
test.txt

Use initramfs

To use initramfs (which forces the kernel to use an in-memory root filesystem), execute the following command:

make menuconfig

then, select:

Filesystem images

  • cpio the root filesystem (for use as an initial RAM filesystem)
  • Compression method (gzip)

Edit the file board/kristech/pigeon_rb100/rpi-firmware/config.txt and uncomment the following line:

#initramfs rootfs.cpio.gz

Edit the file board/kristech/pigeon_rb100/genimage-pigeon_rb100.cfg and uncomment the following line:

# "rootfs.cpio.gz"

The Linux kernel will not use the root filesystem from the mmcblk0p2 partition. Instead, it will load the root filesystem from the rootfs.cpio.gz file. Any changes made during runtime will be lost after a system reboot.

After booting, you can verify whether initramfs is being used by:

# dmesg | grep initramfs
[ 0.841264] Trying to unpack rootfs image as initramfs...
# free
total used free shared buffers cached
Mem: 408440 66760 341680 56 0 52656
-/+ buffers/cache: 14104 394336
Swap: 0 0 0