Rockchip Uboot is compiled and programmed separately
- This article mainly introduces the compilation and programming of RK Uboot and related build scripts.
Preparation
-
Source code preparation:
- Get it from the official:
git clone https://github.com/rockchip-linux/u-boot.git
- Copy from the SDK provided by the development board manufacturer:
cp -rfp sdk/u-boot .
- Get it from the official:
-
rkbin
preparation (U-Boot dependency):- Get it from the official:
git clone https://github.com/rockchip-linux/rkbin.git
- Copy from the SDK provided by the development board manufacturer:
cp -rfp sdk/rkbin .
- Get it from the official:
-
Tool chain preparation (taking gcc 10.3 64-bit as an example):
- Obtained from
arm
official website: gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.xz - Versions of gcc below 10.3 are available from linaro
- Copy from the SDK provided by the development board manufacturer:
cp -rfp prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/ .
- Obtained from
-
Directory preparation:
mv rkbin u-boot/ mkdir -p u-boot/toolchain mv gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/ u-boot/toolchain/
make.sh
-
make.sh is not only a compilation script, but also a packaging and debugging tool. Can be used to disassemble and package firmware.
//Help command ./make.sh help // compile ./make.sh board // Build firmware according to board_defconfig configuration ./make.sh env // Generate fw_printenv tool //output Output the build products in the current directory, including uboot/trust/loader images //Package firmware ./make.sh uboot // Package uboot ./make.sh trust // Package trust ./make.sh loader // Package loader // disassembly ./make.sh elf // Disassemble elf file, use -D parameter by default ./make.sh map // Open u-boot.map ./make.sh sym // Open u-boot.sym
Modify make.sh
- Modify
RKBIN_TOOLS
toRKBIN_TOOLS=rkbin/tools
- If
TOOLCHAIN_ARM64
exists, modifyTOOLCHAIN_ARM64
totoolchain/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin
- If
CROSS_COMPILE_ARM64
exists, modifyCROSS_COMPILE_ARM64
totoolchain/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin
The connection between make.sh and rkbin
- rkbin: used to store bins, scripts, and packaging tools that are not open source for RK. When U-Boot is compiled, it will index relevant files from this warehouse and package them to generate loader, trust, and uboot firmware.
- The
rkbin/RKBOOT/xxx.ini
file and therkbin/RKTRUST/xxx.ini
file specify the firmware that needs to be packaged. - In make.sh, use the statement
${RKBIN}/RKBOOT/${RKCHIP_LOADER}MINIALL.ini
to specify the ini file to be used.RKCHIP_LOADER
is generally the platform name. Taking rk3588 as an example, the ini file used isrkbin/RKBOOT/RK3588MINIALL.ini
.
Firmware compilation
- Taking rv1126 as an example, execute the command
./make.sh rv1126
, and the actual configuration file used is./configs/rv1126_defconfig
.
Compiled product
-
Compile output, taking rv1126 as an example:
//Fit format firmware packaging process and referenced ini files FIT description: FIT Image with U-Boot/OP-TEE/MCU Created: Wed Oct 18 15:43:39 2023 Image 0 (uboot) Description: U-Boot (32-bit) Image 1 (optee) Description: OP-TEE Image 2 (fdt) Description: U-Boot dtb Default Configuration: 'conf' Configuration 0 (conf) Description: rv1126-evb pack loader ok.(rv1126_spl_loader_v1.08.108.bin)(0.01) pack loader okay! Input: /home/ubuntu/rv1126/uboot/rv1126_uboot_v2017.9/rkbin/RKBOOT/RV1126MINIALL.ini /home/ubuntu/rv1126/uboot/rv1126_uboot_v2017.9 //uboot packaging process and referenced ini files Image(no-signed, version=0): uboot.img (FIT with uboot, trust...) is ready Image(no-signed): rv1126_spl_loader_v1.08.108.bin (with spl, ddr, usbplug) is ready pack uboot.img okay! Input: /home/ubuntu/rv1126/uboot/rv1126_uboot_v2017.9/rkbin/RKTRUST/RV1126TOS.ini
-
For the closed-source uboot of the front-end loader, taking rk3399pro as an example, the output product is:
rk3399pro_loader_vx.xx.xxx.bin
idbloader.img
uboot.img
trust.img
- Generally,
rk3399pro_loader_vx.xx.xxx.bin
is renamed toMiniLoaderAll.bin
- idbloader.img and rk3399pro_loader_vx.xx.xxx.bin are the same product, but the packaging methods are different.
-
For the open source uboot of the front-end loader, taking rv1126 as an example, the output product is:
rv1126_spl_loader_vx.xx.xxx.bin
uboot.img
, firmware in fit format, does not have trust.img. The trust binary is packaged in uboot.img.- Generally,
rv1126_spl_loader_vx.xx.xxx.bin
is renamed toMiniLoaderAll.bin
Firmware burning
Use the programming tool
-
The
RKDevTool
tool provided in the SDK, the directory issdk/tools/windows/RKDevTool
. -
Open the programming tool and connect the development board to the computer through
usb
. -
Put the development board into
Maskrom
mode orLoader mode (U-Boot)
. At this time, the lower left corner of the tool will prompt that a device has been found. -
To import the configuration, right-click in the download configuration area, select “Import Configuration”, select ParameterFile in “File Type”, and find the parameter file.
-
Select the partition and file to be burned (the loader partition must be selected). For the first time burning, the partition file (parameter.txt) must be selected, and then click Execute to complete the burning.
-
rk3399pro parameter.txt example:
FIRMWARE_VER: 8.1 MACHINE_MODEL: RK3399PRO MACHINE_ID: 007 MANUFACTURER: RK3399PRO MAGIC: 0x5041524B ATAG: 0x00200800 MACHINE: 3399PRO CHECK_MASK: 0x80 PWR_HLD: 0,0,A,0,1 TYPE: GPT CMDLINE: mtdparts=rk29xxnand:0x1f80@0x40(miniloader),0x400@0x1fc0(ubootenv),0x2000@0x4000(uboot),0x2000@0x6000(trust),0x10000@0x8000(boot),0x300000@0x18000 (recovery),-@ 0x318000(rootfs:grow)
-
The corresponding relationship between the files and partitions that need to be burned by rk3399pro uboot:
Partition File miniloader MiniLoaderAll.bin uboot uboot.img trust trust.img -
rv1126 parameter.txt example:
FIRMWARE_VER: 8.1 MACHINE_MODEL: RV1126 MACHINE_ID: 007 MANUFACTURER: RV1126 MAGIC: 0x5041524B ATAG: 0x00200800 MACHINE: 0xffffffff CHECK_MASK: 0x80 PWR_HLD: 0,0,A,0,1 TYPE: GPT CMDLINE: mtdparts=rk29xxnand:0x1f80@0x40(miniloader),0x400@0x1fc0(ubootenv),0x2000@0x4000(uboot),0x10000@0x6000(boot),0x100000@0x16000(recovery),-@0x116000( rootfs:grow)
-
Correspondence between files and partitions that need to be burned in rv1126 uboot:
Partition File miniloader MiniLoaderAll.bin uboot uboot.img
Use dd command
-
Prerequisite: Can log in to the development board.
-
For the closed-source uboot of the front-end loader, take rk3399pro as an example and execute the following command:
dd if=idbloader.img of=/dev/mmcblk0 bs=1M seek=64 dd if=uboot.img of=/dev/mmcblk0 bs=1M seek=16384 dd if=trust.img of=/dev/mmcblk0 bs=1M seek=24576
-
For the open source uboot of the front-end loader, take rv1126 as an example and execute the following command:
dd if=MiniLoaderAll.bin of=/dev/mmcblk0 bs=1M seek=64 dd if=uboot.img of=/dev/mmcblk0 bs=1M seek=16384