Buildroot for reTerminal
Introduction
Buildroot is an easy-to-use tool that simplifies and automates the process of building a complete Linux system for an embedded system, using cross-compilation.
In order to achieve this, Buildroot is able to generate a cross-compilation toolchain, a root filesystem, a Linux kernel image and a bootloader for your target. Buildroot can be used for any combination of these options, independently (you can for example use an existing cross-compilation toolchain, and build only your root filesystem with Buildroot).
It has a simple structure that makes it easy to understand and extend. It relies only on the well-known Makefile language. Buildroot is an open source project and many developers contribute to it daily.
By following the guide below, you will be able to build your own reTerminal system image using Buildroot. So let's get started!
Compile Buildroot Source Code
Manual Compilation on Local Machine
Now we will move on to manually compiling the system image for reTerminal using Buildroot.
note: This guide was written after testing on a host PC with Ubuntu 20.04 installed. However, it will work for other Linux systems.
- Step 1. Prepare the development environment on the host PC by installing the following packages (git, gcc and make)
sudo apt update
sudo apt install git
sudo apt install build-essential
Note: If you already have the above packages installed. You can skip it.
- Step 2. Clone the following GitHub repo
git clone --depth=1 https://github.com/Seeed-Studio/seeed-linux-buildroot.git -b master
- Step 3. Navigate to the seeed-linux-buildroot directory
cd seeed-linux-buildroot
Compile with the default configuration for reTerminal
Type the following to start compiling with the default reTerminal configuration
make reTerminal_64_defconfig
make
Compile with your own configuration for reTerminal
Type the following to install the necessary package to compile with your own configuration
sudo apt install libncurses-dev
- Step 5. Type the following to open the buildroot configuration window
make menuconfig
You can use this configuration window and navigate through the options available and customize the image according to your needs. Also if you click Save and Exit from this window without making any changes, the default reTerminal configuration will be loaded.
Find the Compiled Image
Once the compilation is successful, navigate to seeed-linux-buildroot/output/images
and you will find the compiled image as sdcard.img
Download Already Compiled Image
If you want to download a reTerminal system image which is already compiled using Buildroot, you can proceed to the steps below.
Step 1. Open this link to enter the Actions page of seeed-linux-buildroot GitHub repo
Step 2. Click on the latest Seeed reTerminal buildroot workflow
- Step 3. Under Artifacts, click on buildroot deploy to start downloading the image
Note: After the downloading the image, extract the image to obtain the sdcard.img file
Flash the Image to reTerminal
Now we will move onto flashing the image to the eMMC of the CM4 on the reTerminal.
Follow the steps in this wiki and pay attention to the following step:
Note: When you open Raspberry Pi Imager, click CHOOSE OS, select Use custom and choose the downloaded sdcard.img file.
First Boot on reTerminal
After we flash the system image to the reTerminal, power on the reTerminal. Here you will see the kernel log pop up on the reTerminal LCD and at last a demo application will open which is made using Qt.
The boot up time of the default system image is around 30 seconds
Analyze Buildroot Image
As mentioned earlier, Buildroot is a very powerful tool, it can rely on third-party libraries and tools, can quickly build what we need. If you want to understand the Buildroot compilation time, dependencies, size of the resources consumed by the compilation and so on, it is very inconvenient to check through the code. However, Buildroot provides visual analysis tools to analyse the above-mentioned and we only need a few simple commands to use them.
Start by installing the following packages
sudo apt install python3-matplotlib python3-numpy
Generate Dependency Diagrams
One of Buildroot's jobs is to understand the dependencies between packages and make sure they are built in the correct order. These dependencies can sometimes be complex, and for a given system, it is often not easy to understand why one package or another was introduced by Buildroot and built successfully. To help understand dependencies and better understand the role of different components in embedded Linux systems, Buildroot is able to generate dependency diagrams (in PDF format)
- Step 1. Install the following package
sudo apt install graphviz
- Step 2. Generate dependency diagrams
make graph-depends
After the above commands, the dependency diagrams will be generated at seeed-linux-buildroot > output > graphs
as:
- graph-depends.pdf
- graph-depends.dot
Note: Click on the above image to view an enlarged version
Generate Analysis of Size of the Resources Consumed by the Compilation
Buildroot can generate an analysis of the size of the resources consumed by the compilation.
Type the following command
make graph-size
After the above command, the visual analysis files will be generated at seeed-linux-buildroot > output > graphs
as:
- graph-size.pdf
- file-size-stats.csv
- package-size-stats.csv
Note: Click on the above image to view an enlarged version
Test Buildroot Image
To test the above Buildroot image with reTerminal, you can visit the reTerminal Hardware and Interfaces Usage wiki and refer to the steps mentioned.
Resources
- [Webpage] Buildroot Documentation
- [GitHub] seeed-linux-buildroot
Tech Support
Please submit any technical issue into our forum.