文章目录
Bootloader之高通LK介绍:
硬件通电后,bootloader是必须要启动运行的,由bootloader来决定运行recovery系统还是android系统(即使在64bit架构,LK依旧运行在32bit模式)
bootloader进行硬件初始化,读取Linux内核和ramdisk,设置寄存器以及内核命令行参数,并跳转至内核运行主要功能:
- 硬件初始化:设置向量表,MMU,cache,初始化外设
- 从储存器加载boot.img
- kernel授权,生成boot.img的签名与校验(???)
iMX平台的bootloader用的是U-boot和高通不一样。
bootloader的信息来源:Bootloader Control Block
BCB是BootLoader和recovery的通信接口,也是BootLoader和android的通信接口,储存在MISC分区,占用3个page其本身是一个结构体:
struct bootloader_message {
char command[32];
char status[32];
char recovery[1280];
// The 'recovery' field used to be 1024 bytes. It has only ever
// been used to store the recovery command line, so 768 bytes
// should be plenty. We carve off the last 256 bytes to store the
// stage string (for multistage packages) and possible future
// expansion.
char stage[32];
// The 'reserved' field used to be 224 bytes when it was initially
// carved off from the 1024-byte recovery field. Bump it up to
// 1184-byte so that the entire bootloader_message struct rounds up
// to 2048-byte.
char reserved[672];
};
char command[32]:
可能的取值:NULL,boot-recovery,others
当想要进入recovery时更新这个值,结束recovery时,清除这个值,防止重启后再次进入recovery模式
char status[32]:
在完成相应的更新后,recovery会将执行结果写入到这个字段
char recovery[1024]:
可被main system写入,也可被recovery服务程序写入。该文件的内容格式:
"recovery\n<recovery command>\n<recovery command>"
该文件储存的就是一个字符串,必须以recovery\n开头,否则这个字段的所有内容会被忽略.开头之后