Compile Buildroot firmware¶
This chapter describes the compilation and use of the Buildroot firmware.
The Firefly_Linux_SDK source package is relatively large, and the Firefly_Linux_SDK source package can be obtained as follows:Download link
After downloading, verify the MD5 code:
$ md5sum firefly-sdk-20200629.7z d8c52272725ff8a2216fc2be7a92ffc4 firefly-sdk-20200629.7z
After confirming that it is correct, you can unzip:
7z x firefly-sdk-20200629.7z cd firefly-sdk git reset --hard
Note: Be sure to update the remote warehouse after decompression. The following is how to update from github:
#1. Enter the SDK root directory cd firefly-sdk #2. Download remote bundle repository git clone https://github.com/FireflyTeam/bundle.git -b rk3399-linux-bundle #3. If clone fails, you can go to github to download bundle.zip: #4. Update the SDK, and subsequent updates do not need to pull the remote warehouse again, just execute the following command ./bundle/update rk3399-linux-bundle #5. Follow the prompts to update the content to FETCH_HEAD, synchronize FETCH_HEAD to the firefly branch git rebase FETCH_HEAD #6. Update common bundle ./bundle/update common-linux-bundle git rebase FETCH_HEAD
Configure compilatoin environment¶
Install the tools needed to compile and ensure that the tools are properly installed:
sudo apt-get install expect-dev repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler \ gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev python-linaro-image-tools \ linaro-image-tools autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make \ binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget \ libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs git mercurial rsync openssh-client \ subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386 libssl-dev texinfo \ liblz4-tool genext2fs lib32stdc++6 expect
Select the configuration file corresponding to the development board. The configuration file will be linked to
device/rockchip/.BoardConfig.mk, which will be checked to confirm the currently used configuration file:
./build.sh firefly-rk3399-buildroot.mk # file path: `device/rockchip/RK3399/firefly-rk3399-buildroot.mk`
.mk file is configured by default to compile the Buildroot firmware. The following describes the Buildroot configuration:
# Buildroot config export RK_CFG_BUILDROOT=rockchip_rk3399 # Buildroot root filesystem configuration file # file path: `buildroot/configs/rockchip_rk3399_defconfig`
# Recovery config export RK_CFG_RECOVERY=rockchip_rk3399_recovery # Root filesystem configuration file in recovery mode (can be omitted) # file path: `buildroot/configs/rockchip_rk3399_recovery_defconfig`
# rootfs image path export RK_ROOTFS_IMG=buildroot/output/$RK_CFG_BUILDROOT/images/rootfs.$RK_ROOTFS_TYPE # Buildroot root filesystem mirror path # In this case, the file path is in `buildroot/output/rockchip_rk3399/images/rootfs.ext4` # Note: This file path will be generated after the root filesystem is first compiled.
When the compile command is executed, it will be compiled according to the
The automatic compilation will compile and package the firmware
update.img, generate firmware directory
Compile the Buildroot root filesystem and generate the compiled output directory in
./build.sh buildroot # Note: Be sure to compile the Buildroot root filesystem as a normal user to avoid unnecessary errors. # The required packages are automatically downloaded during the compilation process, please stay connected.
Image the parts of the
rockdev directory into firmware
The Buildroot compilation output is saved in the
output directory. The specific directory is determined by the configuration file. This example is saved in the
buildroot/output/rockchip_rk3399 directory. You can then execute
make to compile the root filesystem in this directory.
When fully automated, the
buildroot/output/rockchip_rk3399_recovery directory is generated by default, which is the compiled output directory of
build/contains all source files, including the required host tools and selected packages for Buildroot. This directory contains all Module source code.
host/Tools required for host-side compilation include cross-compilation tools.
images/contains a compressed root filesystem image file.
staging/This directory is similar to the directory structure of the root filesystem. It contains all the header files and libraries generated by the compiler, as well as other development files, but they are not tailored and are too large to be used for the target filesystem.
target/contains the complete root filesystem. Compared to
staging/, it has no development files, no header files, and the binary files are
The default compiled root filesystem does not necessarily meet our needs. We may need to add some third-party packages or modify the configuration options of the package. Buildroot supports graphical configuration to select configurations:
cd buildroot/output/rockchip_rk3399/ # Enter the graphical configuration interface, select the required module, save and exit make menuconfig # Save configuration to configuration file 'buildroot/configs/rockchip_rk3399_defconfig' make savedefconfig #Compile the Buildroot root filesystem make
What you need to know is:
When compiling, Buildroot will automatically get related packages from the network according to the configuration, including some third-party libraries, plug-ins, utilities, etc., placed in the dl/ directory.
The package will be extracted in the
output/build/directory and compiled.
If you want to modify the source code of the package, you can modify it by patching it. The patch is placed in the
package/directory, and Buildroot will patch it when unpacking the package.
The command tool that busybox uses to manage the system can be modified as follows:
cd buildroot/output/rockchip_rk3399/ # Enter the graphical configuration interface, select the required module, save and exit make busybox-menuconfig # Save configuration to configuration file `board/rockchip/common/base/busybox.config` make busybox-update-config make
Overlay root filesystem¶
A filesystem overlay is a tree of files that are copied directly over the target filesystem after it has been built. In this way, we can simply add or modify some files:
private overlays path
public overlays path
buildroot/board/rockchip/rk3399/fs-overlay-64/etc/input-event-daemon.conf will overwrite the filesystem’s