4. Compile Buildroot firmware

This chapter introduces the compilation process of Buildroot firmware. It is recommended to develop in the Ubuntu 18.04 system environment. If you use other system versions, you may need to adjust the compilation environment accordingly.

4.1. Compile SDK

4.1.1. Configuration before compilation

In the device/rockchip/rk356x/ directory, there are configuration files of different board types.

Return to SDK root directory to select the configuration file:

./build.sh aio-3568j-buildroot.mk

The configuration file will be linked to device/rockchip/.BoardConfig.mk, check the file to verify whether the configuration is successful.

Related configuration introduction:

# Target arch
export RK_ARCH=arm64 # 64-bit ARM architecture
# Uboot defconfig
export RK_UBOOT_DEFCONFIG=firefly_rk3568 # u-boot configuration file
# Kernel defconfig
export RK_KERNEL_DEFCONFIG=firefly_linux_defconfig # kernel configuration file
# Kernel dts
export RK_KERNEL_DTS=firefly-rk3568-aioj # dts file
# Buildroot config
export RK_CFG_BUILDROOT=rockchip_rk3568 # Buildroot configuration
# Recovery config
export RK_CFG_RECOVERY=rockchip_rk356x_recovery # recovery configuration
# parameter for GPT table
export RK_PARAMETER=parameter-buildroot-fit.txt # Partition table
# rootfs image path
export RK_ROOTFS_IMG=rockdev/rootfs.${RK_ROOTFS_TYPE} # root filesystem path

4.1.2. Select Accessories to Compile

Under device/rockchip/rk356x/ , in addition to aio-3568j-buildroot.mk, there are other configuration files that come with different accessories

The name of the configuration file indicates the screen and camera used. If the screen is not specified, the default HDMI display is used. If the camera is not specified, the default single camera is used

# For example:
xxxx-buildroot.mk              # Use HDMI + single-camera
xxxx-2cam-buildroot.mk         # Use HDMI + dual-camera
xxxx-mipi-buildroot.mk         # Use mipi + single-camera
xxxx-mipi-2cam-buildroot.mk    # Use mipi + dual-camera

Chose the configuration file you like, execute build.sh to make it effective:

# For example:
./build.sh xxxx-mipi-2cam-buildroot.mk

4.1.3. Automatic compilation

Fully automatic compilation will perform all compilation and packaging operations to generate complete firmware.


4.1.4. Partial compilation

  • Compile u-boot

./build.sh uboot
  • Compile kernel

Notice:Firefly kernel does not come with all kernel features, need extra kernel features please refer to Kernel

./build.sh kernel
  • Compile recovery

./build.sh recovery
  • Compile Buildroot root filesystem

Compiling the Buildroot root filesystem will generate a compilation output directory in buildroot/output:

./build.sh buildroot

# Note: Make sure to compile the Buildroot root filesystem as a normal user to avoid unnecessary errors.

4.1.5. Package the firmware

Update each part of the mirror link to the rockdev/ directory:


Pack the firmware, the generated complete firmware will be saved to the rockdev/pack/ directory.

./build.sh updateimg

4.2. Partition description

4.2.1. parameter partition table

The parameter.txt file contains the partition information of the firmware. Take parameter-buildroot-fit.txt as an example:

Path: device/rockchip/rk356x/parameter-buildroot-fit.txt

MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 0xffffffff
PWR_HLD: 0,0,A,0,1
CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00010000@0x00008000(boot),0x00010000@0x00018000(recovery),0x00010000@0x00028000(backup),0x00040000@0x00038000(oem),0x00c00000@0x00078000(rootfs),-@0x00c78000(userdata:grow)

The CMDLINE attribute is our focus. Taking uboot as an example, 0x00004000 in 0x00002000@0x00004000(uboot) is the starting position of the uboot partition, 0x00002000 is the size of the partition, and so on.

4.2.2. package-file

The package-file file is used to determine the required partition image and image path when packaging the firmware, and it needs to be consistent with the parameter.txt file.

Path: tools/linux/Linux_Pack_Firmware/rockdev/rk356x-package-file

package-file    package-file
bootloader      Image/MiniLoaderAll.bin
parameter       Image/parameter.txt
uboot           Image/uboot.img
misc            Image/misc.img
boot            Image/boot.img
recovery        Image/recovery.img
rootfs          Image/rootfs.img
oem             Image/oem.img
userdata        Image/userdata.img
backup          RESERVED