大体上看了一下boot0的代码,没有找到交叉编译的工具,所以也没有编译实验一下(即以下分析可能有错).
boot0的代码在./lichee/boot/boot0目录下:
1. 开始的代码
这部分代码准备了c语言的环境,并跳到c函数Boot0_C_part中
Boot0.slichee/boot/boot0/Boot0.s
-
INCLUDE boot0_i.inc
-
IMPORT Boot0_C_part
-
IMPORT set_pll
-
PRESERVE8
-
AREA init, CODE, READONLY
-
CODE32
-
ENTRY
-
initialize
-
//设置当前运行SVC模式
-
mrs r0, cpsr
-
bic r0, r0, #ARMV7_MODE_MASK
-
orr r0, r0, #ARMV7_SVC_MODE
-
orr r0, r0, #( ARMV7_IRQ_MASK | ARMV7_FIQ_MASK ) ;// After reset, ARM automaticly disables IRQ and FIQ, and runs in SVC mode.
-
bic r0, r0, #ARMV7_CC_E_BIT ;// set little-endian
-
msr cpsr_c, r0
-
-
-
//关mmu, data cache, icache, flow prediction,align
-
mrc p15, 0, r0, c1, c0
-
bic r0, r0, #( ARMV7_C1_M_BIT | ARMV7_C1_C_BIT ) ;// disable MMU, data cache
-
bic r0, r0, #( ARMV7_C1_I_BIT | ARMV7_C1_Z_BIT ) ;// disable instruction cache, disable flow prediction
-
bic r0, r0, #( ARMV7_C1_A_BIT) ;// disable align
-
mcr p15, 0, r0, c1, c0
-
-
//为运行C语言设置栈
-
ldr sp, =BOOT0_STACK_BOTTOM
-
//调用C函数set_pll,设置cpu频率
-
bl set_pll
-
//调用C函数Boot0_C_part
-
bl Boot0_C_part
-
-
b . ;// infinite loop
-
END
2. 进入
然后调用文件Boot0_C_part.c中的Boot0_C_part
-
void Boot0_C_part( void )
-
{
-
__u32 status;
-
__s32 dram_size;
-
//将boot0的代码由 Load$$Boot0_RW_ZI$$Base复制到Image$$Boot0_RW_ZI$$Base
-
move_RW( );
-
//清bss
-
clear_ZI( );
-
//设置了各个clock,具体哪个没看
-
timer_init();
-
//初始化串口,以后就可以打印了
-
UART_open( BT0_head.prvt_head.uart_port, (void *)BT0_head.prvt_head.uart_ctrl, 24*1000*1000 );
-
//打印
-
print_version();
-
-
//以下就是一些初始化
-
...
-
//在文件./lichee/boot/config/storage_media_cfg/nand/storage_media_cfg.h中配置了启动设备
-
#if SYS_STORAGE_MEDIA_TYPE == SYS_STORAGE_MEDIA_NAND_FLASH
-
//初始化nand flash,读取nand上的第2块(烧录时boot1写在了这个地方),第2块开头有一些数据记录了boot1的大小,
-
//按这个大小数取整个的boot1到内存的BOOT1_BASE(0x42400000)处
-
status = load_Boot1_from_nand( );
-
#elif SYS_STORAGE_MEDIA_TYPE == SYS_STORAGE_MEDIA_SPI_NOR_FLASH
-
status = load_boot1_from_spinor( );
-
#elif SYS_STORAGE_MEDIA_TYPE == SYS_STORAGE_MEDIA_SD_CARD
-
status = load_boot1_from_sdmmc( (char *)BT0_head.prvt_head.storage_data ); // ????boot1
-
#else
-
#error The storage media of Boot1 has not been defined.
-
#endif
-
-
mmu_disable( ); // disable instruction cache
-
-
if( status == OK )
-
{
-
set_dram_para((void *)&BT0_head.prvt_head.dram_para, dram_size);
-
set_nand_good_block_ratio_para((void *)&BT0_head.prvt_head.storage_data);
-
jump_to( BOOT1_BASE ); //跳到BOOT1_BASE处,开始执行boot1的东东
-
}
-
}
注: boot0的交叉编译工具链是在lichee/boot/config/ARMCC_CROSSTOOL.CFG中有定义的,需要ARMRVDS.不知上哪儿找这个东东.
阅读(3535) | 评论(3) | 转发(2) |