am335x的cpu上电后,执行流程:ROM->MLO(SPL)->u-boot.img
第一级bootloader:引导加载程序,板子上电后会自动执行这些代码,如启动方式(SDcard、SPI、NOR),然后跳转至第二级bootloader。这些代码应该是存放在 176KB 的 ROM 中
第二级bootloader:MLO(SPL),用于硬件初始化,关看门狗,关中断,设置CPU时钟频率、速度、加载uboot.img、dts等操作,MLO文件应该会被映射到 64 KB的 Internal SRAM 中。
第三级bootloader:u-boot.img, C代码的入口
MLO与u-boot执行流程如下:
reset //(arch/arm/cpu/armv7/start.S)
save_boot_params_ret //(arch/arm/cpu/armv7/start.S)
|- disable interrupts
|- cpu_init_cp15 //(arch/arm/cpu/armv7/start.S)
| |- Invalidate L1 I/D
| |- disable MMU stuff and caches
|- cpu_init_crit //(arch/arm/cpu/armv7/start.S)
| |- lowlevel_init //(arch/arm/cpu/armv7/lowlevel_init.S)
| |- Setup a temporary stack
| |- Set up global data
| |- s_init //(arch/arm/cpu/armv7/am33xx/board.c)
| |- watchdog_disable
| |- set_uart_mux_conf
| |- setup_clocks_for_console
| |- uart_soft_reset
|- _main //(arch/arm/lib/crt0.S)
|(MLO)如果是 MLO 文件
|- board_init_f //(arch/arm/cpu/armv7/am33xx/board.c)
| |- board_early_init_f //(arch/arm/cpu/armv7/am33xx/board.c)
| | |- prcm_init
| | |- set_mux_conf_regs
| |- sdram_init //(board/ti/am335x/board.c) 初始化 DDR
|- spl_relocate_stack_gd
|- board_init_r //(common/spl/spl.c) 【完成u-boot.img dts加载】
|- ...
|- spl_load_image //根据不同的启动方式加载 u-boot 镜像,
|- jump_to_image_no_args //进入u-boot代码运行
|(U-Boot)如果是U-Boot 镜像
|- board_init_f //(common/board_f.c)
| |- ...
| |- initcall_run_list(init_sequence_f)
| |- ...
|
|- relocate_code //(arch/arm/lib/relocate.S) 代码重定位
|- relocate_vectors //(arch/arm/lib/relocate.S) 向量表重定义
|- Set up final (full) environment
|- board_init_r //(common/board_r.c)
|- initcall_run_list(init_sequence_r)//初始化各种外设
|- main_loop()