dm3730 xload启动过程略解
困惑于前面的博文中提到的xload启动的问题,这次仔细的看了一下,也从网上学习了一些xload的启动过程。
从内部的fireware启动xload开始,xload首先加载的是x-load.lds:
[html]
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
cpu/omap3/start.o (.text)
*(.text)
}
. = ALIGN(4);
.rodata : { *(.rodata) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
.got : { *(.got) }
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
_end = .;
}
从这段代码的text代码段中可以看出,入口函数的ENTRY 为start函数,位于cpu/omap3/start.s中,这部份代码完成了汇编和C语言的交互,部分代码如下所示:
[html]
.globl _start
_start:
b reset <span style="color:#FF6666;"> <span style="color:#FF0000;">//首先跳入reset函数,不再返回</span></span>
ldr pc, _hang
。。。。。。
_hang:
.word do_hang
.word 0x12345678
.word 0x12345678
.word 0x12345678
.word 0x12345678
.word 0x12345678
.word 0x12345678
.word 0x12345678 /* now 16*4=64 */
.global _end_vect
_end_vect:
.balignl 16,0xdeadbeef
/*
*************************************************************************
*
* Startup Code (reset vector)
*
* do important init only if we don't start from memory!
* setup Memory and board specific bits prior to relocation.
* relocate armboot to ram
* setup stack
*
*************************************************************************
*/
_TEXT_BASE:
.word TEXT_BASE
.globl _armboot_start
_armboot_start:
.word _start
/*
* These are defined in the board-specific linker script.
*/
.globl _bss_start
_bss_start:
.word __bss_start
.globl _bss_end
_bss_end:
.word _end
/*
* the actual reset code
*/
reset:
/*
* set the cpu to SVC32 mode
*/
.......
next:
......
bl cpy_clk_code /* put dpll adjust code behind vectors */ <span style="color:#FF0000;">//完成clk的初始化</span>
/* the mask ROM code should have PLL and others stable */
bl cpu_init_crit <span style="color:#FF0000;">//这部分是解决我的问题的关键,这里会调用C语言的内容。</span>
relocate: /* relocate U-Boot to RAM */
。。。。。。。。。。。。
copy_loop:
。。。。。。。。。
/* Set up the stack */
stack_setup:
ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
sub sp, r0, #128 /* leave 32 words for abort-stack */
and sp, sp, #~7 /* 8 byte alinged for (ldr/str)d */
/* Clear BSS (if any). Is below tx (watch load addr - need space) */
clear_bss:
ldr r0, _bss_start /* find start of bss segment */
ldr r1, _bss_end /* stop here */
mov r2, #0x00000000 /* clear value */
clbss_l:
str r2, [r0] /* clear BSS location */
cmp r0, r1 /* are we at the end yet */
add r0, r0, #4 /* increment clear index pointer */
bne clbss_l /* keep clearing till at end */
ldr pc, _start_armboot /* jump to C code */ <span style="color:#FF0000;">//从这边开始,其实是进入C语言加载uboot.bin啦</span>,
<span style="color:#FF0000;background-color: rgb(255, 255, 255);">当然这里会完成串口的初始化</span><span style="color:#FF0000;background-color: rgb(255, 255, 255);">,因此系统的信息只有此时才可以printf,</span>
_start_armboot: .word start_armboot
/*
*************************************************************************
*
* CPU_init_critical registers
*
* setup important registers
* setup memory timing
*
************************************************
补充:Web开发 , Jsp ,