本篇正式从U-Boot开始,其中对很多硬件还不是很理解,许多部分不一定分析的准确,希望在以后的工作中能够解决。
U-Boot版本:
VERSION = 2012
PATCHLEVEL = 04
SUBLEVEL = 01
EXTRAVERSION =
所以在board.cfg中寻找omapl138的那一列,找到的结果:
Target | ARCH | CPU | Board name | Vendor | SoC | Options |
omapl138 | arm | arm926ejs | omapl138 | davinci | davinci | NULL |
从start.S开始:(目录:uboot顶层目录arch\arm\cpu\arm926ejs)
#ifdef CONFIG_SYS_DV_NOR_BOOT_CFG
.globl _start
_start:
.globl _NOR_BOOT_CFG
_NOR_BOOT_CFG:
.word CONFIG_SYS_DV_NOR_BOOT_CFG
b reset
#else
.globl _start
_start:
b reset
#endif
前面分析过,使用的是AIS Nor boot的引导方式,所以在这里,CONFIG_SYS_DV_NOR_BOOT_CFG这个宏是不被使用的,配置文件omapl138.h中也没有配置这个宏来使用
所以直接就从_start这里运行了,b reset,跳转到reset:
/*
* the actual reset code
*/
reset:
/*
* set the cpu to SVC32 mode
*/
mrs r0,cpsr
bic r0,r0,#0x1f
orr r0,r0,#0xd3
msr cpsr,r0
/*这里做了两件事情,一个是将CPU设置为SVC32状态,一个是把外部中断(IRQ)与快速中断(FIQ)禁用*/
</pre><pre name="code" class="plain"> /*
* we do sys-critical inits only at reboot,
* not when booting from ram!
*/
#ifndef CONFIG_SKIP_LOWLEVEL_INIT /*这里不准备这么做*/
bl cpu_init_crit
#endif
/* Set stackpointer in internal RAM to call board_init_f */
/*这里开始初始化栈指针,并在内部的RAM中去运行C函数board_init_f*/
call_board_init_f:
#ifdef CONFIG_NAND_SPL /* deprecated, use instead CONFIG_SPL_BUILD */ //no
ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)
#else
#ifdef CONFIG_SPL_BUILD // no
ldr sp, =(CONFIG_SPL_STACK)
#else
ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) //yes
#endif
#endif
bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ /*将低7位清零,这里不知道这个的意义所在*/
ldr r0,=0x00000000 /*参数?*/
bl board_init_f /*跳转到board_init_f*/
board_init_f:(顶层目录下:arch/arm/lib/board.c)
void board_init_f(ulong bootflag)
{
bd_t *bd;
init_fnc_t **init_fnc_ptr;
gd_t *id;
ulong addr, addr_sp;
#ifdef CONFIG_PRAM
ulong reg;
#endif
bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
/* Pointer is writable since we allocated a register for it */
gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
/* compiler optimization barrier needed for GCC >= 3.4 */
__asm__ __volatile__("": : :"memory");
memset((void *)gd, 0, sizeof(gd_t));
gd->mon_len = _bss_end_ofs;
#ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = _binary_dt_dtb_start;
#elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */
gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
#endif
/* Allow the early environment to override the fdt address */
gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
(uintptr_t)gd->fdt_blob);
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
hang ();
}