一、u-boot启动流程
第一步:
S5pc100中IROM中的代码 自动将NAND FLASH的前16KB拷贝到SRAM的0x34000 ,然后bootload的第一部分开始执行,初始化DRAM。
第二步:
bootload将nandflash中所有的bootload拷贝到DRAM中。
第三步:
跳转到DRAM中开始执行bootload的第二部分代码。
二、第一阶段启动流程
裁剪之后的start.S文件如下:
.globl _start
_start: b reset
/***********************************设置异常向量表***************************************/
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
_undefined_instruction: .word undefined_instruction
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_abort: .word data_abort
_not_used: .word not_used
_irq: .word irq
_fiq: .word fiq
_pad: .word 0x12345678 /* now 16*4=64 */
.balignl 16,0xdeadbeef
/**************************************设置异常向量表************************************/
_TEXT_BASE:
#TEXT_BASE 0x20f00000
.word TEXT_BASE
_armboot_start:
#_start 0x20f00000
.word _start
/*
* These are defined in the board-specific linker script.
*链接脚本指定:
*__bss_start bss段起始地址
*__end bss段结束地址
*/
_bss_start:
.word __bss_start
_bss_end:
.word _end
/*
* the actual reset code
*/
/******************************设置ARM核为SVC管理模式********************************/
reset:
/*
* set the cpu to SVC32 mode
* 切换ARM核到管理模式
*/
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr,r0
/*****************************设置ARM核为SVC管理模式*********************************/
bl cpu_init_crit
/*********************************搬移u-boot到DRAM************************************/
#if NOR FLASH 启动
relocate: @ relocate U-Boot to RAM
adr r0, _start @ r0
ldr r1, _TEXT_BASE @ test if we run from flash or RAM
cmp r0, r1 @ don't reloc during debug
beq stack_setup
ldr r2, _armboot_start
ldr r3, _bss_start
sub r2, r3, r2 @ r2
add r2, r0, r2 @ r2
copy_loop: @ copy 32 bytes at a time
ldmia r0!, {r3 - r10} @ copy from source address [r0]
stmia r1!, {r3 - r10} @ copy to target address [r1]
cmp r0, r2 @ until source end addreee [r2]
ble copy_loop
#else NAND FLASH 启动
relocate: @ relocate U-Boot to RAM
adr r0, _start @ r0
ldr r1, _TEXT_BASE @ test if we run from DRAM or SRAM
cmp r0, r1 @ don't reloc during debug
beq stack_setup
ldr sp,_TEXT_BASE
ldr r0,_TEXT_BASE
mov r1,#0x0
mov r2,#0x50000
bl copy_uboot_to_dram
#endif
/**************************搬移u-boot到DRAM************************************/
/**********************************设置栈空间****************************************/
/* Set up the stack */
stack_setup:
ldr r0, _TEXT_BASE @ upper 128 KiB: relocated uboot
sub r0, r0, #CONFIG_SYS_MALLOC_LEN @ malloc area [1M + 128KB]
sub r0, r0, #CONFIG_SYS_GBL_DATA_SIZE @ bdinfo [128字节]
sub sp, r0, #12 @ leave 3 words for abort-stack
and sp, sp, #~7 @ 8 byte alinged for (ldr/str)d
/*******************************设置栈空间********************************************/
/**********************************清除BSS段*******************************************/
/* 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
『本文转载自网络,版权归原作者所有,如有侵权请联系删除』