这三个文件是 github 上的 rkbin 项目里面的, 不开源。
rkbin/bin/rk35/rk3568_ddr_1560MHz_v1.08.bin
rkbin/bin/rk35/rk356x_u***plug_v1.08.bin
rkbin/bin/rk35/rk356x_spl_v1.11.bin
RK平台根据前级Loader代码是否开源,目前有两套启动方式:既然说可以替换,那:
// 前级loader闭源
BOOTROM => ddr bin => Miniloader => TRUST => U-BOOT => KERNEL
// 前级loader开源
BOOTROM => TPL => SPL => TRUST => U-BOOT => KERNEL
TPL 相当于 ddr bin,SPL 相当于 miniloader。TPL+SPL 的组合实现了跟 RK 闭源 ddr.bin+miniloader 一致的功能,可相互替换。
TPL是比U-Boot更早阶段的Loader,TPL运行在SRAM中,
其作用是代替ddr bin负责完成DRAM的初始化工作。
TPL是代码开源的版本,ddr bin是代码闭源的版本。
U-Boot TPL 2017.09 (Jan 21 2022 - 19:00:12)
aarch64-linux-gnu-objdump -h ./tpl/elfBinFile #查看数据段
aarch64-linux-gnu-objdump -S ./tpl/elfBinFile #反汇编
TPL和SPL都使用arch/arm/cpu/armv8/start.S做为入口,只是两者编译时下的参数不一样。
E:DevEERockchipu-boot-next-devtplarcharmcpuarmv8.start.o.cmd
/mnt/e/Dev/EE/Rockchip/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -Wp,-MD,tpl/arch/arm/cpu/armv8/.start.o.d -nostdinc -isystem /mnt/e/Dev/EE/Rockchip/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/include -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD -D__ASSEMBLY__ -g -D__ARM__ -mstrict-align -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -fno-common -ffixed-x18 -pipe -march=armv8-a+nosimd -D__LINUX_ARM_ARCH__=8 -I./arch/arm/mach-rockchip/include -c -o tpl/arch/arm/cpu/armv8/start.o arch/arm/cpu/armv8/start.S
E:DevEERockchipu-boot-next-devsplarcharmcpuarmv8.start.o.cmd
/mnt/e/Dev/EE/Rockchip/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -Wp,-MD,spl/arch/arm/cpu/armv8/.start.o.d -nostdinc -isystem /mnt/e/Dev/EE/Rockchip/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/6.3.1/include -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__ -DCONFIG_SPL_BUILD -D__ASSEMBLY__ -g -D__ARM__ -mstrict-align -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -fno-common -ffixed-x18 -pipe -march=armv8-a+nosimd -D__LINUX_ARM_ARCH__=8 -I./arch/arm/mach-rockchip/include -c -o spl/arch/arm/cpu/armv8/start.o arch/arm/cpu/armv8/start.S
对比可以看到, SPL 编译时比 TPL 编译是少定义一个宏: -DCONFIG_TPL_BUILD
1.9 TPL/SPL/U-Boot-proper
U-Boot 通过使用不同的编译条件可以用同一套代码获取三种不同功能的Loader:TPL/SPL/U-Bootproper。
TPL:运行在 sram 中,负责完成 ddr 初始化;
SPL:运行在 ddr 中,负责完成系统的 lowlevel 初始化、后级固件加载(trust.img 和 uboot.img);
U-Boot proper:运行在ddr中,即我们通常所说的"U-Boot",它负责引导kernel;
U-Boot proper:翻译过来是“真正的U-Boot”的意思。
简单说是代码利用,定义不同的宏,可以编译出不同的代码(TPL/SPL/UBoot proper)
完整编译过一次 u-boot-next-dev 后,目录里面会 tpl 和 spl 两个文件夹。
tpl 文件夹里面有什么 .o 结尾的文件,说明 tpl 使用了对应的 .c .s 结尾的源文件。
.cmd 是对应的编译指令。
查看 E:DevEERockchipu-boot-next-devtplu-boot-tpl.sym, 可得如下文件列表:
0000000000000000 l df *ABS* 0000000000000000 arch/arm/cpu/armv8/start.o
0000000000000000 l df *ABS* 0000000000000000 param.c
0000000000000000 l df *ABS* 0000000000000000 sdram.c
0000000000000000 l df *ABS* 0000000000000000 rk3568.c
0000000000000000 l df *ABS* 0000000000000000 clk_rk3568.c
0000000000000000 l df *ABS* 0000000000000000 bootrom.c
00000000fdcc1458 l O .data 0000000000000068 brom_ctx
0000000000000000 l df *ABS* 0000000000000000 tpl.c
0000000000000000 l df *ABS* 0000000000000000 rk_atags.c
0000000000000000 l df *ABS* 0000000000000000 cpu.c
0000000000000000 l df *ABS* 0000000000000000 generic_timer.c
0000000000000000 l df *ABS* 0000000000000000 cache_v8.c
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/cpu/armv8/exceptions.o
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/cpu/armv8/cache.o
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/cpu/armv8/tlb.o
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/cpu/armv8/transition.o
0000000000000000 l df *ABS* 0000000000000000 fwcall.c
0000000000000000 l df *ABS* 0000000000000000 cpu-dt.c
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/cpu/armv8/smccc-call.o
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/lib/crt0_64.o
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/lib/setjmp_aarch64.o
0000000000000000 l df *ABS* 0000000000000000 spl.c
0000000000000000 l df *ABS* 0000000000000000 zimage.c
0000000000000000 l df *ABS* 0000000000000000 bootm-fdt.c
0000000000000000 l df *ABS* 0000000000000000 sections.c
0000000000000000 l df *ABS* 0000000000000000 stack.c
0000000000000000 l df *ABS* 0000000000000000 tpl/arch/arm/lib/gic_64.o
0000000000000000 l df *ABS* 0000000000000000 interrupts_64.c
0000000000000000 l df *ABS* 0000000000000000 stacktrace_64.c
0000000000000000 l df *ABS* 0000000000000000 cache.c
0000000000000000 l df *ABS* 0000000000000000 psci-dt.c
0000000000000000 l df *ABS* 0000000000000000 board_init.c
0000000000000000 l df *ABS* 0000000000000000 sdram_common.c
0000000000000000 l df *ABS* 0000000000000000 sdram_rk3568.c
0000000000000000 l df *ABS* 0000000000000000 serial-uclass.c
0000000000000000 l df *ABS* 0000000000000000 ns16550.c
0000000000000000 l df *ABS* 0000000000000000 part.c
SoC Boot Stage(sram 阶段):
===================================================================
stage1:
代码:Soc rom with system_sram
作用:search TPL -> copy TPL into system_sram -> jumpto TPL
stage2:
代码:TPL with system_sram => SPL with ddr_mem
作用:init ext_ddr_ram -> copy SPL_in_sytem_ram into ext_ddr_ram
-> jumpto SPL_in_ext_ddr_ram
=> SPL 加载 u-boot FIT Image,解包,jumpto bl31
stage3:
代码:u-boot-proper、bl31、bl32、op-tee、OSKernel
作用:开始区分安全和非安全环境,并初始化之,
让安全环境运行 op-tee,
让非安全环境运行 u-boot-proper, 继续后面的启动流程(比如加载 OSKernel 等)
这部分可能理解得有错。
更多回帖