目录
1.init_sequence_r
uboot启动,首先遍历结构体 init_sequence_r 的函数,函数内部着重分析initr_sunxi_plat、main_loop 两个函数的细则
static init_fnc_t init_sequence_r[] = {
...
initr_sunxi_plat //完成flash的初始化,见下定义
...
initr_env //对应的调试信息:Loading Environment from
...
sunxi_burn_key //对应的调试信息:try to burn key
sunxi_keydata_burn_by_usb
...
initr_net //初始化网络,未用
...
clou_init //厂家自研功能可添加在此
...
main_loop //主函数遍历
s = bootdelay_process()
s = env_get("bootdelay");
s = env_get("bootcmd");
autoboot_command(s)
abortboot(stored_bootdelay) //延时期间可终止uboot运行
__abortboot(bootdelay)
printf("Hit any key to stop autoboot: %2d ", bootdelay);
printf("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>"); //调试信息输出:### main_loop: bootcmd="run sunxi_sprite_test"
run_command_list(s, -1, 0);
sprite_test read //见下定义的 sprite_test 函数
}
run_command_list中运行的命令为run sunxi_sprite_test,这里非常重要,决定了接下来要执行的动作,调用 sunxi_sprite_test 函数,具体详见内部的细节,sunxi_sprite_test 可通过控制台进入uboot的命令接口,输入 printenv 命令查看,信息如下。
uboot阶段进入控制台的环境变量查看,sunxi_sprite_test 被重定向为 sprite_test read,
=> printenv
bootcmd=run sunxi_sprite_test
bootdelay=0
console=ttyS0,115200
fdtcontroladdr=5be66e70
sunxi_sprite_test=sprite_test read
而 sprite_test 属于uboot的命令,具体如下
U_BOOT_CMD(
sprite_test, 2, 0, do_sprite_test,
"do a sprite test",
"NULL"
);
2.initr_sunxi_plat
该阶段函数主要完成:初始化flash设备树、初始化spi设备、flash探测(分区创建)
initr_sunxi_plat
sunxi_flashmap_init //初始化flash设备树
init_spi_all() //初始化spi,包括spi设备树初始化
sunxi_flash_init_ext() //flash初始化
tick_printf("workmode = %d,storage type = %d\n

文章详细描述了UBoot在启动时如何遍历`init_sequence_r`结构体,重点分析了`initr_sunxi_plat`对Flash设备的初始化,包括设备树、SPI和分区创建。`sprite_test`命令的执行流程也被详细展开,涉及到了spinand的初始化和分区操作。整个过程展示了uboot启动及硬件初始化的关键步骤。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



