Env

Systemt: Ubuntu 22.04

Content

首先克隆仓库:

❯ git clone --depth=1  https://github.com/Caesar-github/u-boot
# 这是rkbin仓库,至于为什么克隆见https://blog.505218.xyz/2024/08/23/rk3568%E7%A7%BB%E6%A4%8Duboot/
❯ git clone --depth=1 [email protected]:Caesar-github/rkbin.git

执行以下命令:

cd uboot && ./make.sh rk3568

生成以下文件:

ls rk356x_spl_loader_v1.13.112.bin
rk356x_spl_loader_v1.13.112.bin
ls uboot.img
uboot.img

其中rk356x_spl_loader_v1.13.112.bin是由rkbin仓库的ddr init.binminiloader合并成的,了解原理并手动合成可以看https://blog.505218.xyz/2024/08/23/rk3568%E7%A7%BB%E6%A4%8Duboot/

uboot.img则是由fit/u-boot.itb拷贝来的,fit/u-boot.itb是一个FIT格式的镜像文件,由fit/u-boot.its指导生成,观察fit/u-boot.its文件如下:


/*
* Copyright (C) 2020 Rockchip Electronic Co.,Ltd
*
* Simple U-boot fit source file containing ATF/OP-TEE/U-Boot/dtb/MCU
*/

/dts-v1/;

/ {
description = "FIT Image with ATF/OP-TEE/U-Boot/MCU";
#address-cells = <1>;

images {

uboot {
description = "U-Boot";
data = /incbin/("u-boot-nodtb.bin");
type = "standalone";
arch = "arm64";
os = "U-Boot";
compression = "none";
load = <0x00a00000>;
hash {
algo = "sha256";
};
};
atf-1 {
description = "ARM Trusted Firmware";
data = /incbin/("./bl31_0x00040000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0x00040000>;
hash {
algo = "sha256";
};
};
atf-2 {
description = "ARM Trusted Firmware";
data = /incbin/("./bl31_0xfdcc1000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xfdcc1000>;
hash {
algo = "sha256";
};
};
atf-3 {
description = "ARM Trusted Firmware";
data = /incbin/("./bl31_0x0006a000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0x0006a000>;
hash {
algo = "sha256";
};
};
atf-4 {
description = "ARM Trusted Firmware";
data = /incbin/("./bl31_0xfdcd0000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xfdcd0000>;
hash {
algo = "sha256";
};
};
atf-5 {
description = "ARM Trusted Firmware";
data = /incbin/("./bl31_0xfdcce000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0xfdcce000>;
hash {
algo = "sha256";
};
};
atf-6 {
description = "ARM Trusted Firmware";
data = /incbin/("./bl31_0x00068000.bin");
type = "firmware";
arch = "arm64";
os = "arm-trusted-firmware";
compression = "none";
load = <0x00068000>;
hash {
algo = "sha256";
};
};
optee {
description = "OP-TEE";
data = /incbin/("tee.bin");
type = "firmware";
arch = "arm64";
os = "op-tee";
compression = "none";

load = <0x8400000>;
hash {
algo = "sha256";
};
};
fdt {
description = "U-Boot dtb";
data = /incbin/("./u-boot.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
hash {
algo = "sha256";
};
};
};

configurations {
default = "conf";
conf {
description = "rk3568-evb";
rollback-index = <0x0>;
firmware = "atf-1";
loadables = "uboot", "atf-2", "atf-3", "atf-4", "atf-5", "atf-6", "optee";

fdt = "fdt";
signature {
algo = "sha256,rsa2048";

key-name-hint = "dev";
sign-images = "fdt", "firmware", "loadables";
};
};
};
};

可以看到这里面将bl31文件分成了很多块和u-boot-nodtb.bin还有u-boot.dtb放入了u-boot.itbbl31文件是一个trust文件,也就是ATF (Arm trust firmware)ATF 主要负责在启动uboot之前把CPU从安全的EL3切换到 EL2,然后跳转到uboot,并且在内核启动后负责启动其他的CPU。

Ref

https://www.cnblogs.com/zyly/p/17389525.html#_label0