说明
本文仅针对讯为的iTop4412开发板的uboot(主线版本为u-boot-2017-11)启动进行分析,其他开发板整体步骤可能一致,具体细节可能差别很大,本文仅供参考。暂时贴出示意,后面有时间在总结;可用点灯大法跟踪运行流程,贴出点灯代码。
- asm版本
ldr r0, =0x11000100 /* GPL2_0 CON */
mov r1, #1
str r1, [r0] /* set bit 0, output mode */
ldr r0, =0x11000104 /* GPL2_0 DAT */
mov r1, #1
str r1, [r0] /* set bit 0, to light led */
- C版本
static inline void light_led(void)
{
__asm__ volatile(
"ldr r0, =0x11000100 \n\t"
"mov r1, #1 \n\t"
"str r1, [r0] \n\t"
"ldr r0, =0x11000104 \n\t"
"mov r1, #1 \n\t"
"str r1, [r0] \n\t"
);
}
启动流程示意
开机CPU复位到verctor
SPL, BL1
arch/arm/lib/vectors.S _start----> b reset
arch/arm/cpu/armv7/start.S ---> 设置vector base(即_start)
---> cpu_init_cp15()
---> cpu_init_crit()
---> lowlevel_init(WEAK, default arch/arm/cpu/armv7/lowlevel_init.S)
---> _main (arch/arm/lib/crt0.S)
arch/arm/lib/crt0.S _main ----> 设置sp地址为CONFIG_SPL_STACK(初始化C执行环节)
---> board_init_f(arch/arm/mach-exynos/spl_boot.c)
---> do_lowlevel_init(arch/arm/mach-exynos/lowlevel_init.c)
---> get_reset_status(arch/arm/mach-exynos/power.c)
---> actions = DO_CLOCKS | DO_MEM_RESET | DO_POWER
---> set_ps_hold_ctrl(arch/arm/mach-exynos/power.c)
---> GPX0_2 as output, GPX0UP 0_1 as pull-up?
---> system_clock_init()
---> debug_uart_init()
---> mem_ctrl_init()
---> copy_uboot_to_ram(arch/arm/mach-exynos/spl_boot.c)
---> get_boot_mode(arch/arm/mach-exynos/power.c)
---> get_irom_func(调用iROM中提供的的Function)
---> 调用获得的func,读取SD/MMC中uboot镜像到内存
---> (*uboot)()
U-BOOT, BL2
arch/arm/lib/vectors.S _start----> b reset
arch/arm/cpu/armv7/start.S ---> 设置vector base(即_start)
---> cpu_init_cp15()
---> cpu_init_crit()
---> lowlevel_init(WEAK, default arch/arm/cpu/armv7/lowlevel_init.S)
---> _main (arch/arm/lib/crt0.S)
arch/arm/lib/crt0.S _main ----> 设置sp地址为CONFIG_SYS_INIT_SP_ADDR(初始化C执行环节)
---> board_init_f(common/board_f.c)
---> 轮流执行init_sequence_f中的接口,如:
---> board_early_init_f(board/samsung/common/board.c)
---> exynos_early_init_f(板级文件.c)
---> print_cpuinfo(CPU: Exynos4412 @ 1 GHz)
---> show_board_info (Model: TOPEET..., Board: ...)
---> reverse memory and reloc
---> board_init_r(./common/board_r.c)
---> 轮流执行init_sequence_r中的接口,如:
---> board_init(./board/samsung/common/board.c)
---> exynos_init(板级文件.c)
---> board_early_init_r(未使用)
---> initr_net()
---> run_main_loop()
---> for(;;) main_loop();
common/main.c main_loop ----> Hit any key to stop autoboot,> autoboot
----> 如果按下,进入hush等待输入