This article first introduces buildroot, then introduces the basic composition of tinkerboard2's Linux sdk, buildroot is included in the Linux sdk, then introduces the specific porting, configuration, compilation steps, and finally shows the running effect.
Buildroot is a framework for embedded Linux systems and can be considered as a root filesystem, similar to debian\yocto. The entire Buildroot is composed of .mk files (equivalent to the individual sub-Makefiles of the Linux kernel) and Config,in (equivalent to the Kconfig of the Linux kernel) configuration files. Similar to the Linux kernel, it compiles a complete rootfs by modifying menuconfig to modify the configuration and supports packaging this rootfs into images of different file system types (e.g. ext4 ubifs ramdisk, etc.). This image is burned to the board and can be run by kernel kernel boot.
Currently Rockchip sdk contains three file systems, buildroot, debian and yocto. debian is the official system pushed by asus, its advantage is that it is compatible with some of the applications on the Raspberry Pi, and it comes with a desktop, so if you want to use tinkerboard2 as a personal computer, you can consider it. But for embedded devices, debian is too bloated. Currently in the embedded device above the more used is still buildroot + QT, buildroot is characterized by its tailorable, customizable.
buildroot is located in the Linux SDK directory of tinkerboard2 and can be downloaded at
After downloading and unpacking, the root directory of the sdk is described as follows
├── app # example app, such as qtlauncher ├── br.log ├── buildroot # The directory where buildroot is stored ├── build.sh -> device/rockchip/tinker_board_2/build.sh # build script for uboot kernel and rootfs ├── device # Directory for uboot kernel and rootfs configuration for each board type ├── docs # Official rk documentation ├── envsetup.sh -> buildroot/build/envsetup.sh #buildroot's environment variables ├── external # rk hardware related libraries, scripts, etc., such as mpp codec library, rkupdate upgrade function, etc. ├── kernel #Linux kernel source code ├── Makefile -> buildroot/build/Makefile #This makefile points to buildroot, so executing make in sdk will have the same effect as executing make in the buildroot folder ├── mkfirmware.sh -> device/rockchip/tinker_board_2/mkfirmware.sh # script for packaging firmware ├── prebuilts # Cross-compilation tools ├── rkbin #rk's bootloader optee and other non-open source firmware ├── tools #rk's packaging and burning tools ├── u-boot # uboot source code ├── tools
The contents of the buildroot folder are as follows
├─ arch # cpu-related configuration ├── board # board-level configuration ├─ boot ├── build #Compile-related scripts are stored in this directory ├── CHANGES ├── Config.in #General config file ├── Config.in.legacy ├── configs #Specific defconfig files are stored in this directory ├── COPYING ├── DEVELOPERS ├── dl #Downloaded app source tarballs are stored here ├── docs #buidroot's documentation ├── fs #File system related build scripts are stored here ├─ linux ├── Makefile #General makefile ├── Makefile.legacy ├── output # output directory for compilation, Rockchip sdk can support multiple compilation configurations for one project, each compilation configuration will have a separate output directory here ├── package # The build and configuration files for each app ├── README ├── support # Scripts, configuration files that provide functional support for Bulidroot ├── system # Builds, configuration files for making the root filesystem ├── toolchain # Build and configure files for cross toolchain └── utils ├── utils
RK's Linux sdk already contains uboot kernel and rootfs, and the whole sdk is managed using repo. When compiling, first specify a mk file in the device directory under the sdk root directory, the mk file specifies the specific config for uboot, kernel and rootfs, and then use build.sh under the sdk directory to compile with one click or specify different parameters to compile uboot, kernel or rootfs
If you want to build the buildroot firmware yourself, you can read the steps in this section, or if you just want to experience it, you can go to the end, where there are links to download the firmware
According to the previous description, RK's Linux sdk uses the configuration file in the device directory and the compilation script (softlinked to the sdk top-level directory) to achieve one-click compilation of all and individual compilation of each module, so this first step is to modify the file in the device directory
- Write the .mk file and reference it
You can refer to tinkerboard2's debian mk file to write a buildroot mk file
cp BoardConfig-rk3399-tinker_board_2-debian.mk BoardConfig-rk3399-tinker_board_2-buildroot.mk
Then modify the following items
export RK_OEM_DIR=oem_normal export RK_ROOTFS_SYSTEM=buildroot export RK_CFG_BUILDROOT=rockchip_rk3399_tinkerboard2
Save the changes, then execute them in the sdk root directory
. /build.sh device/rockchip/tinker_board_2/BoardConfig-rk3399-tinker_board_2-buildroot.mk
- Copy the related scripts
In the sdk of tinkerboard2, ASUS only provides the build script for debian by default, so here you have to copy a build script for buildroot
cp device/rockchip/common/mk-buildroot.sh device/rockchip/tinker_board_2/mk-buildroot.sh
I have provided the zip archive of device/rockchip/tinker_board_2 folder directly here for download
In the previous step, RK_CFG_BUILDROOT was specified, and the following configuration file is to be created
Go to buildroot/configs
Then copy a copy of the official rk3399 config
cp rockchip_rk3399_defconfig rockchip_rk3399_tinkerboard2_defconfig
Then modify rockchip_rk3399_tinkerboard2_defconfig directly, it includes a lot of other config files here, these .config files are all located under buildroot/configs/rockchip, you can see exactly which apps it opens for compilation You can see exactly which apps it opens for compilation.
If you don't want the functionality of a module, just delete it, for example
If you don't want audio-related features, you can remove the
#include "audio.config" #include "audio_gst.config"
If you don't need video codec function, you can remove
#include "video_mpp.config" #include "video_gst.config" #include "video_gst_rtsp.config"
If you don't need camera related functions, you can remove
#include "camera.config" #include "camera_gst.config"
buildroot has a feature, if a module has not been compiled, add it later, you can use incremental compilation, no need to clean the whole recompile, but if a module has been compiled, later to delete, we need to clean out, so the first compile, it is recommended to delete the unneeded first
After modifying the defconfig file, use the following command to reference it
source envsetup.sh rockchip_rk3399_tinkerboard2
Then, as we described earlier, the makefile under the sdk root directory is soft-linked to the buildroot makefile, so you can execute it under the sdk root directory
You can get the following screen
The modifications here are similar to those for kernel, you can add or trim some tools in the configuration screen to customize the system features as needed. You can type / to enter the search screen, type in what you are looking for and press enter to search. After you find it, press Y to select this option. After you configure it, select the left and right keys on the keyboard to move to save, then press enter, it will be saved to .config, which is a temporary file, then move to Exit and press enter to exit.
Then use the command
Save this configuration file back to rockchip_rk3399_tinkerboard2.
I provide a sample defconfig file here, which can be copied directly to buildroot/configs/rockchip_rk3399_tinkerboard2_defconfig for replacement
After completing the previous step, execute the following command in the sdk root directory to start compiling
unset LD_LIBRARY_PATH source envsetup.sh rockchip_rk3399_tinkerboard2 make
to start the compilation process
buildroot's compilation process uses a lot of open source software, it has to download the source package from the git of each open source package, if the network speed is not good, the download will fail and the following compilation error will appear
Solution: You can use Xunlei to download the downloaded file directly from this website, put the downloaded file into the buildroot/dl directory of virtual machine Rockchip sdk, and then recompile it.
If you see the following message, the compilation has been completed
The compiled image is in
The rootfs.ext4 is only the root file system image for buildroot, it needs to be packaged with the uboot kernel etc. as a complete firmware, which can be burned to the board using rk's burner tool or other methods. In the case of compiled buildroot, execute directly in the sdk root directory
Executing this command will compile the uboot kernel sequentially, because buildroot has been compiled before, so if nothing has been changed, it will not be recompiled, and eventually the rk packaging script will be executed to package the uboot kernel and rootfs. Finally, you can get update.img in the rockdev directory, and this image can be burned to the board to run
Burning reference to the following section, first make the development board into maskrom mode
After entering bootrom, select the firmware to start burning, refer to the following figure
Here I used a 7-inch touch screen to demonstrate the screen and interaction, 7-inch touch screen adaptation method refer to the following article, only need to modify the kernel part can be
Inside the demo video below, the bootup script runs QLauncher, which is a desktop written in QT and supports launching several QT graphical applications. Then use qfm, which is a file browser written in QT, to browse the files on the USB drive, which contains an mp4 video, click on the video to call qplayer to play the video
Where qplayer supports rk's mpp codec library to accelerate video codecs, so you can see that the playback is still smooth
Here I will provide a compiled firmware that can be used for testing, this firmware supports 7 inch touch screen by default