Compile Ubuntu firmware

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

Preparatory work

Set up compilation environment

sudo apt-get install repo git ssh make gcc libssl-dev liblz4-tool \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler python-pip ncurses-dev python-pyelftools

Download Firefly_Linux_SDK

  • Method One

Download via repo:

mkdir ~/proj/rk356x_linux_release_20211019/
cd ~/proj/rk356x_linux_release_20211019/
repo init --no-clone-bundle --repo-url -u -b master -m rk356x_linux_release.xml
  • Method Two

Download Firefly_Linux_SDK sub-volume compressed package: Firefly_Linux_SDK Source

After downloading, verify the MD5 code:

$ md5sum rk356x_linux_release_v1.2.0_20211019_split_dir/*firefly_split*
b633414d69240faa0c3bd755c255ede8  rk356x_linux_release_v1.2.0_20211019_split_dir/rk356x_linux_release_v1.2.0_20211019_firefly_split.file0
5cb1e2b63bbb4e3595c731038f6723fd  rk356x_linux_release_v1.2.0_20211019_split_dir/rk356x_linux_release_v1.2.0_20211019_firefly_split.file1
e06c0f29fd5a870e0942139a1877a470  rk356x_linux_release_v1.2.0_20211019_split_dir/rk356x_linux_release_v1.2.0_20211019_firefly_split.file2
4e14fbf72ccbb9b87f81d83a256205b0  rk356x_linux_release_v1.2.0_20211019_split_dir/rk356x_linux_release_v1.2.0_20211019_firefly_split.file3
be8b003703b51e7220e52bb36439a357  rk356x_linux_release_v1.2.0_20211019_split_dir/rk356x_linux_release_v1.2.0_20211019_firefly_split.file4

After confirming that it is correct, you can unzip:

Attention: To avoid unnecessary errors, please do not unzip the SDK in shared folders, mounted folders or non-english directories.

mkdir ~/proj/
cd ~/proj/
cat path/to/rk356x_linux_release_v1.2.0_20211019_split_dir/*firefly_split* | tar -xzv

Sync Code

Execute the following command to synchronize the code:

# Enter the SDK root directory
cd ~/proj/rk356x_linux_release_20211019/

# Sync
.repo/repo/repo sync -l
.repo/repo/repo sync -c --no-tags
.repo/repo/repo start firefly --all

You can use the following command to update the SDK later:

.repo/repo/repo sync -c --no-tags


$ tree -L 1
├── app
├── buildroot # Buildroot root filesystem build directory
├── -> device/rockchip/common/ # Compile script
├── debian # Debian root filesystem compilation directory
├── device # Compile related configuration files
├── distro
├── docs # Documentation
├── -> buildroot/build/
├── external
├── kernel
├── Makefile -> buildroot/build/Makefile
├── -> device/rockchip/common/ # Link script
├── prebuilts # Cross compilation toolchain
├── rkbin
├── -> device/rockchip/common/ # Flash script
├── tools # Tools directory
├── u-boot
└── yocto

Build Linux-SDK

Precompile Configuration

There are configuration files for different board in device/rockchip/rk356x/, select the configuration file:


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

Configruation content:

# Target arch
export RK_ARCH=arm64 # 64-bit ARM
# Uboot defconfig
export RK_UBOOT_DEFCONFIG=firefly-rk3566 # u-boot configuration
# Kernel defconfig
export RK_KERNEL_DEFCONFIG=firefly_linux_defconfig # kernel configuration
# Kernel dts
export RK_KERNEL_DTS=rk3566-firefly-roc-pc # dts file
# parameter for GPT table
export RK_PARAMETER=parameter-ubuntu-fit.txt # partition table
# rootfs image path
export RK_ROOTFS_IMG=ubuntu_rootfs/rk356x_ubuntu_rootfs.img # filesystem path

Select Accessories to Compile

Select Screen

Choose different DTS in :

# Kernel dts
export RK_KERNEL_DTS=rk3566-firefly-roc-pc # HDMI (Default)
# Or
export RK_KERNEL_DTS=rk3566-firefly-roc-pc-mipi101_HSTM101014_BE45_B1 # DM-M10R800 V2 MIPI

Select Camera

In the DTS that selected in previous step, include different dtsi to select camera:

*                               select camera
* using single camera xc7160        --->  rk3566-firefly-roc-pc-cam-8ms1m.dtsi
* using dual camera gc2053/gc2093   --->  rk3566-firefly-roc-pc-cam-2ms2m.dtsi
// Using single-camera module CAM-8MS1M
#include "rk3566-firefly-roc-pc-cam-8ms1m.dtsi"
// Or using dual-camera module CAM-2MS2MF
#include "rk3566-firefly-roc-pc-cam-2ms2m.dtsi"


Partial compilation

  • u-boot

./ uboot
  • kernel

./ kernel
  • recovery

./ recovery

Download Ubuntu filesystem

7z x ubuntu-aarch64-rootfs.7z
  • Move filesystem to ubuntu_rootfs/

mkdir ubuntu_rootfs
mv ubuntu-aarch64-rootfs.img ubuntu_rootfs/rk356x_ubuntu_rootfs.img

Pack the firmware

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

RK firmware

RK firmware is the firmware packaged in Rockchip’s proprietary format, and can be flashed to eMMC or SD card with the tools provided by Rockchip (Note: If there is no special instruction, the firmware mentioned on WIKI defaults to RK firmware) .

# Pack RK firmware
./ updateimg

RAW firmware

RAW firmware is a kind of firmware that can be flashed to the storage device in a bit-by-bit copy mode, and is the original image of the storage device. Different from the RK firmware, currently it only supports flashing to SD card to boot with Etcher tool.

Etcher official download link

# Package RAW firmware
./ rawimg

Automatic compilation

The automatic compilation will perform the above compilation and packaging operations to generate RK firmware.


Partition table


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

path: device/rockchip/rk356x/parameter-ubuntu-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),0x00c00000@0x00038000(rootfs),-@0x00c38000(userdata:grow)

The CMDLINE attribute is where we are concerned. Take uboot as an example. In 0x00002000@0x00004000(uboot), 0x00004000 is the starting position of the uboot partition, 0x00002000 is the size of the partition, and so on.


The package-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.

path: tools/linux/Linux_Pack_Firmware/rockdev/rk356x-ubuntu-package-file

# NAME          Relative path
#HWDEF          HWDEF
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
userdata        RESERVED
backup          RESERVED