u-boot 程序执行流程记录(am335x 开发板)

Author:DriverMonkey

Mail:[email protected]

QQ:196568501

欢迎交流(承接各类嵌入式外包项目-wince,linux,单片机,上位机开发)

进入u-boot

file: start.s

 b    reset   // 跳转到复位执行函数


...


reset:

//1.set the cpu to SVC32 mode


....

bl    cpu_init_crit

.....


cpu_init_crit:

...

bl    lowlevel_init        @ go setup pll,mux,memory

...


file:lowlevel_init.s

lowlevel_init:

...

bl    s_init   //从这里调到c语言初始化代码

..


evm.c

void s_init(void)
{
    /* Can be removed as A8 comes up with L2 enabled */
    l2_cache_enable();

    /* WDT1 is already running when the bootloader gets control
     * Disable it to avoid "random" resets
     */
    __raw_writel(0xAAAA, WDT_WSPR);
    while(__raw_readl(WDT_WWPS) != 0x0);
    __raw_writel(0x5555, WDT_WSPR);
    while(__raw_readl(WDT_WWPS) != 0x0);

#ifdef CONFIG_SPL_BUILD
    /* Setup the PLLs and the clocks for the peripherals */
    pll_init();

    /* Enable RTC32K clock */
    //rtc32k_enable();  //masked by DriverMonkey

    /* UART softreset */
    u32 regVal;
    u32 uart_base = DEFAULT_UART_BASE;

    enable_uart0_pin_mux();
    /* IA Motor Control Board has default console on UART3*/
    /* XXX: This is before we've probed / set board_id */
    if (board_id == IA_BOARD) {
        uart_base = UART3_BASE;
    }

    regVal = __raw_readl(uart_base + UART_SYSCFG_OFFSET);
    regVal |= UART_RESET;
    __raw_writel(regVal, (uart_base + UART_SYSCFG_OFFSET) );
    while ((__raw_readl(uart_base + UART_SYSSTS_OFFSET) &
            UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK);

    /* Disable smart idle */
    regVal = __raw_readl((uart_base + UART_SYSCFG_OFFSET));
    regVal |= UART_SMART_IDLE_EN;
    __raw_writel(regVal, (uart_base + UART_SYSCFG_OFFSET));

    /* Initialize the Timer */
    init_timer();

    preloader_console_init();
    config_am335x_ddr3();//added by DriverMonkey
    //config_am335x_ddr();
#endif
}


Start.s

call_board_init_f:
    ldr    sp, =(CONFIG_SYS_INIT_SP_ADDR)
    bic    sp, sp, #7 /* 8-byte alignment for ABI compliance */
    ldr    r0,=0x00000000
    bl    board_init_f


spl.c

void board_init_f(ulong dummy)
{
    /*
     * 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
     */
    debug(">>board_init_f()++\n");
    printf("board_init_f\n");
    relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
}


Start.s

relocate_code:
    mov    r4, r0    /* save addr_sp */
    mov    r5, r1    /* save addr of gd */
    mov    r6, r2    /* save addr of destination */

    /* Set up the stack

你可能感兴趣的:(u-boot 程序执行流程记录(am335x 开发板))