How to modify the size of uboot partition in Rockchip Android
This article is applicable to Rockchip platform RK3566/RK3568/RK3588
U-Boot firmware
The uboot firmware format of RK3566/RK3568/RK3588 is FIT format and is guided by SPL.
FIT format
A highly flexible firmware format supported by U-Boot mainline. Firmware such as U-Boot, trust, and mcu are packaged together as uboot.img.
The magic of the image file of uboot.img is "d0 0d fe ed", and fdtdump uboot.img
you can view the firmware header with the command.
00000000 d0 0d fe ed 00 00 06 00 00 00 00 58 00 00 04 c4 |...........X....|
00000010 00 00 00 28 00 00 00 11 00 00 00 10 00 00 00 00 |...(............|
Usually, uboot.img is packaged with multiple backups in order to deal with situations that may cause firmware damage, such as power failure during the OTA upgrade process.
firmware | serving size | Number of packs |
---|---|---|
FIT uboot.img | 2MB | 2 |
As can be seen from the above table, the default size of uboot.img is 4MB.
How to modify the size and number of copies of a single copy:
- FIT format: Change configuration parameters: CONFIG_SPL_FIT_IMAGE_KB and CONFIG_SPL_FIT_IMAGE_MULTIPLE. Respectively indicate the size of a single copy (unit: KB) and the number of packed copies.
The specific code is modified as follows:
- Modify the single copy size CONFIG_SPL_FIT_IMAGE_KB to 3MB
@sys2_206:~/4_Android12_29_sdk/u-boot$ git diff
diff --git a/configs/rk3568_defconfig b/configs/rk3568_defconfig
index d2742454eb..1de98e7373 100644
//RK3568/RK3566平台
--- a/configs/rk3568_defconfig
+++ b/configs/rk3568_defconfig
@@ -218,3 +218,4 @@ CONFIG_RK_AVB_LIBAVB_USER=y
CONFIG_OPTEE_CLIENT=y
CONFIG_OPTEE_V2=y
CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION=y
+CONFIG_SPL_FIT_IMAGE_KB=3072
diff --git a/configs/rk3588_defconfig b/configs/rk3588_defconfig
index 49b75d6ff6..70ecc9d983 100644
//RK3588/RK3588S平台
--- a/configs/rk3588_defconfig
+++ b/configs/rk3588_defconfig
@@ -224,3 +224,4 @@ CONFIG_RK_AVB_LIBAVB_USER=y
CONFIG_OPTEE_CLIENT=y
CONFIG_OPTEE_V2=y
CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION=y
+CONFIG_SPL_FIT_IMAGE_KB=3072
- Update the spl file
After the above modification, you need to compile and update the spl firmware synchronously
@sys2_206:~/4_Android12_29_sdk/u-boot$ ./make.sh rk3568 --spl-new
Copy the compiled spl/u-boot-spl.bin to the rkbin directory to update the corresponding spl file
@sys2_206:~/4_Android12_29_sdk/u-boot$ cp spl/u-boot-spl.bin ../rkbin/bin/rk35/rk356x_spl_v1.12.bin
Note: Spl needs to be recompiled after each synchronization of the RK code to avoid being overwritten
- If the total size of the two uboots exceeds the size of the uboot partition defined in parameter.txt (the default is 4MB), you need to modify the size of the uboot partition in the parameter. For specific modification methods, please refer to the document: Method for modifying partition size on Rockchip Android platform
When the size of uboot single file is not enough to compile, the following error will be reported:
********boot_merger ver 1.2********
Info:Pack loader ok.
pack loader okay! Input: /home2/liupingzhang/rk3566/RK3566_Android11.0_SDK_V1.1.1_Linux/rkbin/RKBOOT/RK3566MINIALL.ini
/home2/liupingzhang/rk3566/RK3566_Android11.0_SDK_V1.1.1_Linux/u-boot
ERROR: pack uboot.img failed! fit/uboot.itb actual: 2171904 bytes, max limit: 2097152 bytes