Detailed Explanation of Buildroot Package Management Mechanism and Specific Package Upgrade Solutions

Introduction

Buildroot is an open-source tool for building embedded Linux systems, with its package management principles centered around “automated builds” and “dependency management.” It achieves full process control from source acquisition to target system generation through modular design.

Core Architecture of Buildroot Package Management

Buildroot adopts a layered architecture and modular design, mainly consisting of the following parts:

  1. 1. Configuration System: Based on Kconfig (similar to Linux kernel configuration), it provides a graphical interface for selecting packages and configuration options through <span>make menuconfig</span>.
  2. 2. Package Description Files: Each package corresponds to a <span>.mk</span> file (located in the <span>package/</span> directory), defining the source acquisition method, compilation rules, dependencies, etc.
  3. 3. Build System: Based on Makefile, it automates the processing of packages in stages (download, extract, configure, compile, install).
  4. 4. Dependency Resolver: Automatically analyzes the dependencies between packages to determine the build order (e.g., compile the toolchain before compiling applications).
  5. 5. Target Filesystem Generator: Installs the compiled packages into the target filesystem, generating deployable images.

Buildroot Package Upgrade Methods

Buildroot does not have a dedicated command for package management like OpenWRT’s opkg; application software generally needs to be compiled under the SDK framework to customize the root filesystem. The official SDK released for RK3568 is customized based on a specific version of Buildroot, and the application software version follows the SDK.

If you want to upgrade a specific application software version, you need to prepare the source code yourself and modify the corresponding package description file, then compile and build it yourself.

Detailed Upgrade of ipTables in Buildroot

The default version of ipTables in the Buildroot 2023 SDK is 1.6.1. This article will take upgrading it to version 1.8 as an example to detail the steps involved in upgrading Buildroot packages.

Obtaining the Source Code

First, download the Buildroot SDK that includes ipTables version 1.8 from the official source. It is not recommended to download the standalone ipTables source code from other channels or the official software package, as the Buildroot baseline usually applies patches to the application software baseline to adapt to Buildroot, including modifications related to known issues and Makefile compilation dependency rules.

Download the Buildroot-2024.02.9 package, which includes ipTables 1.8.

wget https://buildroot.org/downloads/buildroot-2024.02.9.tar.gz

Extract:

# Extracting the package

tar xc buildroot-2024.02.9.tar.gz
buildroot-ef2af4b67f3403fc0feaca8a07d1733f17c6b316

Extract the ipTables package and its dependencies, and update them to the corresponding directory in the Buildroot SDK.

package\iptables
package\libnftnl

Compilation

Compile the application normally or compile the entire root filesystem. During the compilation process, the following error occurred: <span>no suitable libnftnl found, :no suitable libnftnl found.</span>

# Compilation error [iptables 1.8.8 Configuring] no suitable libnftnl found, :no suitable libnftnl found.
checking for libnftnl >= 1.1.6... no
*** Error: no suitable libnftnl found. ***
    Please install the 'libnftnl' package
    Or consider --disable-nftables to skip
    iptables-compat over nftables support

The solution is to download libnftnl version 1.6 and recompile Buildroot to successfully upgrade.

Postscript

The Buildroot kernel has already set up the ipTables-related components, but executing commands prompts errors. This issue exists in both version 1.6.1 and 1.8, and the subsequent detailed introduction will provide solutions.

root@RK356X:/# iptables -t nat -A POSTROUTING -s 192.18.28.100/24 -j SNAT --to-source 190.99.99.99
iptable nat: No chain/target/match by that name. or ERROR: 0 not a valid target)

Leave a Comment