Detailed Configuration of Embedded Linux Buildroot Environment: Building an Efficient and Stable Development Platform

In the fields of IoT and edge computing, the Raspberry Pi 4B, with its quad-core Cortex-A72 architecture and rich interfaces, has become an ideal platform for embedded Linux development. By using Buildroot to create a customized development environment,

developers can quickly obtain a lightweight and highly controllable Linux system. This article is aimed at intermediate developers with a basic understanding of Linux, providing a detailed analysis of the entire process from toolchain configuration to system deployment.

Hardware and Software Requirements

Hardware Requirements:

  • Raspberry Pi 4B (Broadcom BCM2711, 4GB RAM)
  • Class 10 or higher SD card (32GB)
  • 5V/3A Type-C power supply
  • USB-TTL debugging serial cable

Software Requirements:

  • Host Operating System: Ubuntu 22.04 LTS
  • Buildroot 2023.02.2
  • armv8l-linux-gnueabihf-gcc 10.3.0
  • Linux Kernel 5.15.78

Overview of the Development Environment

This solution adopts a layered build architecture:

Host toolchain → Kernel compilation → Root filesystem construction → SD card image generation

Buildroot, as the core build system, automatically manages the dependencies of the kernel, toolchain, and packages, generating a complete system image that can be directly flashed.

Preparing the Host Development Environment

# Install basic dependencies
sudo apt-get update
sudo apt-get install -y git make gcc g++ patch unzip rsync libssl-dev bc

Cross-Compilation Toolchain Configuration

Obtain the precompiled toolchain from the official Buildroot:

wget https://buildroot.org/downloads/buildroot-2023.02.2.tar.gz
tar xvf buildroot-2023.02.2.tar.gz
cd buildroot-2023.02.2

Kernel Source Acquisition and Configuration

Automatically integrate the kernel through Buildroot:

make raspberrypi4_defconfig
make menuconfig  # Enter configuration interface

Key configuration items:

Target packages → Networking → Enable wpa_supplicant
System configuration → Set root password
Kernel → Linux Kernel version 5.15.x

Building the Root Filesystem

# Select Raspberry Pi 4B configuration
make raspberrypi4_64_defconfig
# Start the build process (approximately 90 minutes)
make -j$(nproc)

System Boot Configuration

After the build is complete, the sdcard.img image is generated in the output/images directory. Check the partition structure using fdisk:

Device         Start      End  Sectors  Size Type
sdcard.img1     2048   526335   524288  256M W95 FAT32
sdcard.img2   526336 62333951 61807616 29.5G Linux filesystem

Deploying the System on the Development Board

Use the dd command to write to the SD card:

sudo dd if=output/images/sdcard.img of=/dev/sdX bs=4M status=progress
sync

Environment Testing and Verification

  1. Connect via UART for serial debugging (baud rate 115200)
  2. Check if the system boot log is complete
  3. Verify network functionality:
ping -c4 www.buildroot.org

Common Issues and Solutions

Q1: SD card boot failure, stuck on rainbow screenA: Check if the power supply meets the requirements, confirm that the image is correctly flashed, and try regenerating the dtb file.

Q2: Network interface not recognizedA: Update kernel configuration to ensure the BCM54213PE driver is enabled:

Device Drivers → Network device support → Broadcom PHYs → Enable BCM54213PE

Q3: Root filesystem mount failureA: Check the integrity of output/images/rootfs.ext4 and confirm partition table alignment.

Development Environment Optimization

  1. Enable ccache to speed up compilation:
make menuconfig
# Enter Build options → Enable compiler cache
  1. Integrate VSCode remote development:
# Install Remote-SSH extension
# Configure cross-debugging toolchain path

Leave a Comment