u-boot-2011.09
am335x启动流程:
1.rom code(详见芯片手册)
2.spl(Secondary Program Loader)
根据spl/u-boot-spl.lds<===arch/arm/cpu/armv7/omap-common/u-boot-spl.lds:
arch/arm/cpu/armv7/start.o (.text)
_start:
b reset
bl save_boot_params://arch/arm/cpu/armv7/ti81xx/lowlevel_init.S
#ifdef CONFIG_SPL_BUILD
ldr r4, =ti81xx_boot_device
ldr r5, [r0, #BOOT_DEVICE_OFFSET]//rom启动后,将一个BootParametersStructure的指针保存在r0,其中r0+8保存boot device(详见芯片手册)
and r5, r5, #BOOT_DEVICE_MASK//取低八位
str r5, [r4]//将boot device保存在变量ti81xx_boot_device
#endif
bx lr
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
bl cpu_init_crit//只有在spl中才执行,uboot中不执行
bl lowlevel_init//lowlevel_init.S,设置堆栈,跳转到c函数
bl s_init//evm.c
l2_cache_enable();//cache.S,cp15
//关看门狗
pll_init();***
preloader_console_init();//spl.c
//#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8")//r8寄存器保存gd的地址
//static gd_t gdata __attribute__ ((section(".data")));
gd = &gdata;//spl阶段r8=gd=&gdata,位于sram (MLO的data段)
config_am335x_ddr();
#endif
bl board_init_f//spl.c
/*
* We call relocate_code() with relocation target same as the
* CONFIG_SYS_SPL_TEXT_BASE. This will result in relocation getting
* skipped. Instead, only .bss initialization will happen. That's
* all we need //设置重定向地址为sram基地址,故意跳过relocation,只清bbs段
*/
relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
relocate_code://start.S
mov r4, r0 /* save addr_sp */ //栈地址=CONFIG_SPL_STACK
mov r5, r1 /* save addr of gd */ //gd地址=&gdata(位于data段)
mov r6, r2 /* save addr of destination */ //重定位地址=CONFIG_SPL_TEXT_BASE
/* Set up the stack */
stack_setup:
mov sp, r4
/*
adr伪指令相对于pc(运行时确定)。adr的反汇编就是基于PC的add sub指令
位置无关,用于获得_start的真正运行地址(而不是链接地址)
*/
adr r0, _start// adr伪指令相对于pc(运行时确定),当前PC位于sram,所以r0=CONFIG_SPL_TEXT_BASE
cmp r0, r6 // r0=r6 说明在sram中运行
moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */ //r9保存重定向地址的偏移地址,spl中不进行重定向,r9=0
beq clear_bss /* skip relocation */ //跳过relocation,以下代码在spl中没有执行。调用clear_bss
/************ skip relocation in spl ***********/
mov r1, r6 /* r1 <- scratch for copy_loop*/ //r1=sram_start
ldr r3, _image_copy_end_ofs //_image_copy_end_ofs=__image_copy_end - _start
add r2, r0, r3 /* r2 <- source end address */
copy_loop: //在spl中,这段代码是将自己copy给自己。实际上在spl中这段代码没有被调用,因为clear_bss没有返回
ldmia r0!, {r9-r10} /* copy from source address [r0] */
stmia r1!, {r9-r10} /* copy to target address [r1] */
cmp r0, r2 /* until source end address [r2] */
blo copy_loop
/************ skip relocation in spl ***********/
clear_bss:
#ifdef CONFIG_SPL_BUILD
/* No relocation for SPL */
ldr r0, =__bss_start
/*
*u-boot-spl.lds,sdram中的bss = CONFIG_SPL_BSS_START_ADDR = 0x80000000,即sdram起始地址
*CONFIG_SPL_BSS_MAX_SIZE = 0x80000,即MLO的BBS段位于sdram 0x80000000-0x80080000(512k),
*/
ldr r1, =__bss_end__
#endif
mov r2, #0x00000000 /* clear */
clbss_l:str r2, [r0] /* clear loop... */
add r0, r0, #4
cmp r0, r1
bne clbss_l
/*
* We are done. Do not return, instead branch to second part of board
* initialization, now running from RAM.
*/
jump_2_ram:
/*
* If I-cache is enabled invalidate it
*/
#ifndef CONFIG_SYS_ICACHE_OFF
mcr p15, 0, r0, c7, c5, 0 @ invalidate icache
mcr p15, 0, r0, c7, c10, 4 @ DSB
mcr p15
[UBOOT] AM335x 启动流程(u-boot-2011.09)
最新推荐文章于 2022-10-28 17:13:44 发布