u-boot启动流程(一)

来源:互联网 发布:美国编程网站儿童 编辑:程序博客网 时间:2024/05/19 19:59

arch/arm/cpu/armv7/start.S       //这里要看你用的是什么样的cpu,我用的contex A5,所以在armv7目录下

/* Set stackpointer in internal RAM to call board_init_f */call_board_init_f:    ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)     bic sp, sp, #7 /* 8-byte alignment for ABI compliance */#ifndef CONFIG_NAND_SPL    ldr r0,=0x00000000            bl  board_init_f          #else      ldr r0, =(CONFIG_SYS_INIT_SP_ADDR)     ldr r1, =0x00000000           ldr r2, =(CONFIG_SYS_TEXT_BASE)    bl relocate_code          #endif                 
在这里会跳转到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;    /* 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;    for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {        if ((*init_fnc_ptr)() != 0) {            hang ();         }       }       debug ("monitor len: %08lX\n", gd->mon_len);    /*       * Ram is setup, size stored in gd !!     */    debug ("ramsize: %08lX\n", gd->ram_size);
这里会调用init_sequence[ ]里的函数,该数组在该文件中定义,内容如下:

init_fnc_t *init_sequence[] = {#if defined(CONFIG_ARCH_CPU_INIT)      arch_cpu_init,      /* basic arch cpu dependent setup */                                                                                                                     #endif #if defined(CONFIG_BOARD_EARLY_INIT_F)    board_early_init_f,       #endif     timer_init,     /* initialize timer */#ifdef CONFIG_FSL_ESDHC    get_clocks,#endif     env_init,       /* initialize environment */    init_baudrate,      /* initialze baudrate settings */    serial_init,        /* serial communications setup */    console_init_f,     /* stage 1 init of console */      display_banner,     /* say that we are here */#if defined(CONFIG_DISPLAY_CPUINFO)    print_cpuinfo,      /* display cpu info (and speed) */                                                                                                                       #endif #if defined(CONFIG_DISPLAY_BOARDINFO)    checkboard,     /* display board info */                                                                                                                                     #endif #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)                                                                                                                             init_func_i2c,#endif     dram_init,      /* configure available RAM banks */#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)                                                                                                                                  arm_pci_init,#endif     NULL,};