Build Ubuntu firmware

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


Download Firefly_Linux_SDK

  • Method One

Download via repo:

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

Download the SDK source code package.

Download: Linux_SDK.7z

After downloading, verify the MD5 code:

$ md5sum rk3288_linux_release_20210304.tgz
aa713b610db6f08570b2f9645eacbbf6  rk3288_linux_release_20210304.tgz

After confirming that it is correct, you can unzip:

mkdir ~/proj/
cd ~/proj/
tar -zxvf path/to/rk3288_linux_release_20210304.tgz

Sync Code

Execute the following command to synchronize the code:

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

# 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 filesystem
├── -> device/rockchip/common/             # compile script
├── debian                                                  # Debian filesystem
├── device                                                  # config files
├── distro
├── docs                                                    # document
├── -> buildroot/build/
├── external
├── kernel
├── makefile -> buildroot/build/makefile
├── -> device/rockchip/common/   # link script
├── prebuilts                                               # cross-compile toolchain
├── rkbin
├── -> device/rockchip/common/         # flashing script
├── tools
├── u-boot
└── yocto

Set up compilation environment

sudo apt-get install git gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler mtools \
parted libudev-dev libusb-1.0-0-dev python-linaro-image-tools linaro-image-tools libssl-dev \
autotools-dev libsigsegv2 m4 libdrm-dev curl sed make binutils build-essential gcc g++ bash \
patch gzip bzip2 perl tar cpio python unzip rsync file bc wget libncurses5 libglib2.0-dev \
openssh-client lib32stdc++6 gcc-aarch64-linux-gnu libncurses5-dev lzop libssl1.0.0 libssl-dev

Build Linux-SDK

Precompile Configuration

There are configuration files for different board in device/rockchip/rk3288/, 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=arm                                              # 32-bit ARM
# Uboot defconfig
export RK_UBOOT_DEFCONFIG=firefly-rk3288                        # u-boot configuration
# Kernel defconfig
export RK_KERNEL_DEFCONFIG=firefly_linux_defconfig              # kernel configuration
# Kernel dts
export RK_KERNEL_DTS=rk3288-firefly                              # dts file
# parameter for GPT table
export RK_PARAMETER=parameter-ubuntu.txt                        # partition table
# rootfs image path
export RK_ROOTFS_IMG=ubuntu_rootfs/rk3288_ubuntu_rootfs.img     # filesystem path


Partial compilation

  • u-boot

./ uboot
  • kernel

./ kernel
  • recovery

./ recovery

Build Debian filesystem

If you want to use the Debian filesystem, you can do as follows, otherwise, skip this step.

  • Install required packages

sudo apt-get install 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 \
gcc-4.8-multilib-arm-linux-gnueabihf libssl-dev g+conf autotools-dev texinfo liblz4-tool genext2fs \
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 openssh-client subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386
  • Build

./ debian

The generated filesystem will be saved to debian/linaro-rootfs.img; for specific compilation instructions, you can view debian/

  • Use Debian filesystem

Modify the configuration file

# rootfs image path
# export RK_ROOTFS_IMG=ubuntu_rootfs/rk3288_ubuntu_rootfs.img
export RK_ROOTFS_IMG=debian/linaro-rootfs.img

Download Ubuntu filesystem

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

mkdir ubuntu_rootfs
mv ubuntu-armhf-rootfs.img ubuntu_rootfs/rk3288_ubuntu_rootfs.img

Pack the firmware

Update each part of the .img link to the directory rockdev/:


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

./ updateimg

Automatic compilation

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


Partition table


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

path: device/rockchip/rk3288/parameter-ubuntu.txt

MAGIC: 0x5041524B
ATAG: 0x00200800
PWR_HLD: 0,0,A,0,1
CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0x00002000@0x00008000(misc),0x00010000@0x0000a000(boot),0x00010000@0x0001a000(recovery),0x00010000@0x0002a000(backup),0x00600000@0x0005a000(rootfs),-@0x0065a000(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/rk3288-ubuntu-package-file

# NAME          Relative path
#HWDEF          HWDEF
package-file    package-file
bootloader      Image/MiniLoaderAll.bin
parameter       Image/parameter.txt
trust           Image/trust.img
uboot           Image/uboot.img
boot            Image/boot.img
misc            Image/misc.img
recovery        Image/recovery.img
rootfs          Image/rootfs.img
userdata:grow RESERVED
backup          RESERVED