安卓系列教程之ROM系统开发-百问100ask
系统:Android10.0
设备: FireFly RK3399 (ROC-RK3399-PC-PLUS)
之前的文章已经讲解过整体Android源码编译, 里面包含了u-boot, kernel, Android源码的编译, 本文重点讲解,u-boot源码单独编译的方法。让大家对uboot编译出来的镜像有个整体认识。
cd rk3399_Android10.0/u-boot/
./make.sh rk3399
u-boot编译完成之后目录如下所示:
u-boot : 所有源码通过gcc链接生成的elf格式可执行程序, 一般只能在带操作系统的情况才能运行。
u-boot.bin :u-boot elf可执行程序通过objcopy生成的裸奔代码, 主要是将elf头去掉, 头部开始就是指令。
uboot.img :在u-boot.bin文件上增加了一些元数据, 比如加载地址,bin文件大小。
rk3399_loader_v1.24.126.bin : 第一级loader,由bootrom代码加载到soc内部sram中执行, 负责初始化soc,以及外部DDR, 其实MiniLoaderAll.bin就是由该文件拷贝而来。
trust.img:主要是ARM trustzone实现代码,包含BL31、BL32代码, 一般这部分代码不开源。
而在整个RK3399 源码编译出来的镜像中, 就包含以上三个:
uboot.img, MiniLoaderAll.bin, trust.img
u-boot源码中make.sh的用法可以参考如下命令获取:
ldswfun@android:/mnt/ext-disk2/RK/rk3399_Android10.0/u-boot$ ./make.sh help
Usage:
./make.sh [board|sub-command]- board: board name of defconfig
- sub-command: elf*|loader|trust|uboot|--spl|--tpl|itb|map|sym|
- ini: ini file to pack trust/loaderOutput:
When board built okay, there are uboot/trust/loader images in current directoryExample:
1. Build:
./make.sh evb-rk3399 --- build for evb-rk3399_defconfig
./make.sh firefly-rk3288 --- build for firefly-rk3288_defconfig
./make.sh EXT_DTB=rk-kernel.dtb --- build with exist .config and external dtb
./make.sh --- build with exist .config
./make.sh env --- build envtools2. Pack:
./make.sh uboot --- pack uboot.img
./make.sh trust --- pack trust.img
./make.sh trust--- pack trust img with assigned ini file
./make.sh loader --- pack loader bin
./make.sh loader--- pack loader img with assigned ini file
./make.sh --spl --- pack loader with u-boot-spl.bin
./make.sh --tpl --- pack loader with u-boot-tpl.bin
./make.sh --tpl --spl --- pack loader with u-boot-tpl.bin and u-boot-spl.bin3. Debug:
./make.sh elf --- dump elf file with -D(default)
./make.sh elf-S --- dump elf file with -S
./make.sh elf-d --- dump elf file with -d
./make.sh elf-* --- dump elf file with -*
./make.sh--- unwind address(no relocated)
./make.sh--- unwind address(relocated)
./make.sh map --- cat u-boot.map
./make.sh sym --- cat u-boot.sym
make.sh uboot : 打包uboot.img镜像, 实际调用
scripts/uboot.sh --load ${LOAD_ADDR} ${PLAT_UBOOT_SIZE}
rk3399对应的脚本为:
u-boot/scripts/uboot.sh --load 0x00200000
make.sh trust: 打包trust.img镜像, 实际调用:
${SCRIPT_ATF} --ini ${INI_TRUST} ${PLAT_SHA} ${PLAT_RSA} ${PLAT_TRUST_SIZE}
rk3399对应的脚本为:
u-boot/scripts/atf.sh --ini ../rkbin/RKTRUST/RK3399TRUST.ini
make.sh loader: 打包loader镜像
rk3399对应的脚本为:
u-boot/scripts/loader.sh --ini ../rkbin/RKBOOT/RK3399MINIALL.ini
我们通过单独编译u-boot, 大体上了解一下在统一镜像中出现的几个镜像是从哪里来的, 这样后面如果需要改代码, 就知道那些镜像会被重新编译。