[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
Chip defconfig Supports kernel dtb Description rv1108 evb-rv1108_defconfig N \ rk1808 rk1808_defconfig Y \ rk1806 rk1806_defconfig Y \ rk3036 rk3036_defconfig Y \ rk3128x rk3128x_defconfig Y \ rk3128 evb-rk3128_defconfig N \ rk3126 rk3126_defconfig Y \ rk322x rk322x_defconfig Y \ rk3288 rk3288_defconfig Y \ rk3368 rk3368_defconfig Y \ rk3328 rk3328_defconfig Y \ rk3399 rk3399_defconfig Y \ rk3399pro rk3399pro_defconfig Y \ rk3399pro-npu rknpu-lion_defconfig Y \ rk3308 rk3308_defconfig Y \ rk3308-aarch32 rk3308-aarch32_defconfig Y \ px30 px30_defconfig Y \ rk3326 rk3326_defconfig Y \ rk3326-aarch32 rk3326-aarch32_defconfig Y \ rv1126 rv1126_defconfig Y General version rv1126 rv1126-ab.config Y General version + A/B support rv1126 rv1126-emmc-tb.config
rv1126-lp3-emmc-tb.config
rv1126-spi-nor-tb.configY eMMC+DDR3 fast boot
eMMC+LP3 fast boot
Spi Nor+DDR3 fast bootrv1126 rv1126-spi-nor-tiny_defconfig
rv1126-ramboot.config
rv1126-usbplug.configY Spi Nor small capacity
No storage device (memory boot)
usbplug functionrk3566 rk3566.config
rk3566-eink.configY General version
E-book versionrk3568 rk3568_defconfig
rk3568-dfu.config
rk3568-nand.config
rk3568-spl-spi-nand_defconfig
rk3568-aarch32.config
rk3568-usbplug.configY General version
Supports dfu
Supports MLC/TLC/eMMC
SPI-nand dedicated SPL
Supports aarch32 mode
Supports usbplug modeNote: 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 && makeTo update the config fragment file, simply use
./scripts/sync-fragment.sh. For example:./scripts/sync-fragment.sh configs/rv1126-emmc-tb.configEffect: 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 distcleanand 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.