Buildroot with Pigeon computers
This tutorial demonstrates how to build a small custom Linux system for Pigeon computers using Buildroot. Buildroot is a tool that streamlines and automates the creation of a full 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 intended to be executed on Linux systems. This text includes excerpts from the Buildroot user manual.
Prerequisites
In this tutorial, the Debian distribution is utilized on the host machine. Before proceeding, ensure that 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 3 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 utilizing Buildroot is to create a configuration. You should build everything as a regular user; there is no need to have root privileges to configure and utilize 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 wish to modify the Buildroot configuration, execute the following command:
make menuconfig
To adjust the kernel configuration, execute the following command:
make linux-menuconfig
Build system
To begin the building procedure, just run:
make
The process may take a while.
Write an image to eMMC
The Buildroot output images are located in the directory output/images/. You can write the SD card image to the Pigeon computer's eMMC (where X is the drive letter designation) using:
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'll see the banner:
Welcome to Pigeon RB100
pigeon login: root
The default login credentials are as follows: Username: root Password: kristech
Tips
Read-only root filesystem partition
By default, the root filesystem partition is mounted in read-write mode. You can change it to read-only mode by:
make menuconfig
After making the change, proceed to turn off the device:
System configuration
- remount root filesystem read-write during boot
You can also use rw and ro script files in the Pigeon console:
# 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 utilize initramfs (forcing 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 specified line:
#initramfs rootfs.cpio.gz
Edit the file board/kristech/pigeon_rb100/genimage-pigeon_rb100.cfg and uncomment the specified line:
# "rootfs.cpio.gz"
The Linux kernel will not utilize the rootfs from the mmcblk0p2 partition. Instead, it will use the root filesystem from the rootfs.cpio.gz file. Any alterations made at runtime will be lost upon system reboot.
After booting, you can verify if 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