Skip to main content

[TOC]

Compilation and Flashing

Prerequisites​

  • Download rkbin

    This is a tool package repository for storing Rockchip's closed-source binaries, scripts, and packaging tools. During U-Boot compilation, it indexes related files from this repository to generate loader, trust, and uboot firmware. The rkbin and U-Boot projects must be kept at the same directory level.

    Repository download: please refer to the appendix chapter.

  • Download GCC

    The GCC compiler uses gcc-linaro-6.3.1, placed in the prebuilts directory. prebuilts and U-Boot must be at the same directory level. As follows:

    // 32-bit:
    prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf
    // 64-bit:
    prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/

    GCC download: please refer to the appendix chapter

  • Select defconfig

    ChipdefconfigSupports kernel dtbDescription
    rv1108evb-rv1108_defconfigN\
    rk1808rk1808_defconfigY\
    rk1806rk1806_defconfigY\
    rk3036rk3036_defconfigY\
    rk3128xrk3128x_defconfigY\
    rk3128evb-rk3128_defconfigN\
    rk3126rk3126_defconfigY\
    rk322xrk322x_defconfigY\
    rk3288rk3288_defconfigY\
    rk3368rk3368_defconfigY\
    rk3328rk3328_defconfigY\
    rk3399rk3399_defconfigY\
    rk3399prork3399pro_defconfigY\
    rk3399pro-npurknpu-lion_defconfigY\
    rk3308rk3308_defconfigY\
    rk3308-aarch32rk3308-aarch32_defconfigY\
    px30px30_defconfigY\
    rk3326rk3326_defconfigY\
    rk3326-aarch32rk3326-aarch32_defconfigY\
    rv1126rv1126_defconfigYGeneral version
    rv1126rv1126-ab.configYGeneral version + A/B support
    rv1126rv1126-emmc-tb.config
    rv1126-lp3-emmc-tb.config
    rv1126-spi-nor-tb.config
    YeMMC+DDR3 fast boot
    eMMC+LP3 fast boot
    Spi Nor+DDR3 fast boot
    rv1126rv1126-spi-nor-tiny_defconfig
    rv1126-ramboot.config
    rv1126-usbplug.config
    YSpi Nor small capacity
    No storage device (memory boot)
    usbplug function
    rk3566rk3566.config
    rk3566-eink.config
    YGeneral version
    E-book version
    rk3568rk3568_defconfig
    rk3568-dfu.config
    rk3568-nand.config
    rk3568-spl-spi-nand_defconfig
    rk3568-aarch32.config
    rk3568-usbplug.config
    YGeneral version
    Supports dfu
    Supports MLC/TLC/eMMC
    SPI-nand dedicated SPL
    Supports aarch32 mode
    Supports usbplug mode

    Note: If the table differs from the defconfig in the SDK release, refer to the SDK.

  • Introduction to config fragment

    Due to differentiated product requirements on a single platform, a single defconfig is no longer sufficient. Starting from RV1126, config fragment is supported, i.e., overlaying on top of a defconfig.

    For example: rv1126-emmc-tb.config specifies CONFIG_BASE_DEFCONFIG="rv1126_defconfig". When executing ./make.sh rv1126-emmc-tb, it first generates .config using rv1126_defconfig, then overlays the configuration from rv1126-emmc-tb.config onto .config. This command is equivalent to:

    make rv1126_defconfig rv1126-emmc-tb.config && make

    To update the config fragment file, simply use ./scripts/sync-fragment.sh. For example:

    ./scripts/sync-fragment.sh configs/rv1126-emmc-tb.config

    Effect: diffs the configuration differences between the current .config and rv1126_defconfig into the rv1126-emmc-tb.config file.

Firmware Compilation​

Compilation command:

./make.sh [board] // [board]: configs/[board]_defconfig file.

First compilation: Regardless of 32-bit or 64-bit platform, for the first time or when re-specifying a defconfig, the compilation command must specify [board]. For example:

./make.sh rk3399 // build for rk3399_defconfig
./make.sh evb-rk3399 // build for evb-rk3399_defconfig
./make.sh firefly-rk3288 // build for firefly-rk3288_defconfig

Subsequent compilation: Regardless of 32-bit or 64-bit platform, to compile based on the current ".config" without re-specifying [board]:

./make.sh

Note: If strange issues cause compilation failure, try make distclean and recompile.

Firmware generation: After compilation, trust, uboot, and loader are packaged in the U-Boot root directory. Below is the information during packaging:

// Compilation...
....

// uboot packaging process
load addr is 0x60000000!
pack input u-boot.bin
pack file size: 478737
crc = 0x840f163c
uboot version: v2017.12 Dec 11 2017
pack uboot.img success!
pack uboot okay! Input: u-boot.bin

// loader packaging process and referenced ini file
out:rk3126_loader_v2.09.247.bin
fix opt:rk3126_loader_v2.09.247.bin
merge success(rk3126_loader_v2.09.247.bin)
pack loader okay! Input: /home/cjh/rkbin/RKBOOT/RK3126MINIALL.ini

// trust packaging process and referenced ini file
load addr is 0x68400000!
pack file size: 602104
crc = 0x9c178803
trustos version: Trust os
pack ./trust.img success!
trust.img with ta is ready
pack trust okay! Input: /home/cjh/rkbin/RKTRUST/RK3126TOS.ini

// Prompt compilation successful. Note: Even if trust and loader packaging fail, this message still appears, indicating at least uboot.img was generated.
Platform RK3126 is build OK, with new .config(make rk3126_defconfig)

The final flashable firmware is generated in the root directory:

./uboot.img
./trust.img // Note: For fit format firmware, there is no trust.img. The trust binary is packaged inside uboot.img.
./rk3126_loader_v2.09.247.bin

Firmware packaging tool: please refer to the tools chapter.

Firmware Flashing​

Flashing tool:

For Windows/Linux firmware flashing tools, it is recommended to use the tool version from the SDK release or the latest version.

Flashing mode:

RK platforms support two flashing modes: Maskrom mode and Loader mode (U-Boot).

(1) Entering Loader flashing mode:

  • Press and hold Volume+ during boot
  • Press and hold ctrl+d on the host during boot
  • U-Boot command line input: download or rockusb 0 $devtype $devnum

(2) Entering Maskrom flashing mode:

  • Press and hold ctrl+b on the host during boot
  • U-Boot command line input: rbrom

Notes:

  • Currently U-Boot supports two partition table types: RK parameter partition table (old) and GPT partition table (new). To switch from one partition table type to the other, Nand devices must have the entire firmware re-flashed; eMMC devices support replacing the partition table independently.

  • If both partition tables exist on the device, GPT partition table is recognized first. This can be confirmed via boot information:

    ...
    PartType: EFI // Currently using GPT partition table; otherwise prints "PartType: RKPARM"
    ...

Firmware Size​

Please refer to the chapter: RK Architecture => U-Boot Firmware.

Special Packaging​

In addition to compiling code, ./make.sh also integrates firmware packaging functionality. Some additional standalone packaging commands are provided for developers. However, U-Boot must be compiled at least once before using them.

Non-FIT format:

./make.sh trust // Package trust
./make.sh loader // Package loader
./make.sh trust <ini-file> // Specify ini file when packaging trust; otherwise use default ini file
./make.sh loader <ini-file> // Specify ini file when packaging loader; otherwise use default ini file

FIT format:

// Old script:
./make.sh spl // Replace ddr and miniloader with tpl+spl, package as loader
./make.sh spl-s // Replace miniloader with spl, package as loader

// New script:
./make.sh --spl // Replace miniloader with spl, package as loader
./make.sh --tpl // Replace ddr with tpl, package as loader
./make.sh --tpl --spl // Replace ddr and miniloader with tpl and spl, package as loader
./make.sh --spl-new // ./make.sh --spl only packages without compiling; this command recompiles then packages.

How to distinguish old and new scripts? If the new commands work, make.sh is the new script.