此bootloader是根据韦东山先生的开发板而制定的 是一个最小的boot系统 必须首先把内核拷nandflash里面才行。
我们先一步步的完成这个小的bootloader
1. 首先我们需要关闭看门狗:
ldr r0, 0x53000000 //this is the address of watch
mov r1, #0;
str r1, [r0] //disable watch dog
看门狗的地址在0x53000000
我们给他赋值0 即可
设置时钟:
时钟的比例是 FCLK:HCLK:PCLK=1:2:4, HDIVN=1,PDIVN=1
所以应该是:
MDIV 0x5C
PDIV 0x01
SDIV 0x01
这里面 HDIVN : 01
PDIVN:1
然后加入此段代码 进入异步模式
/* 如果HDIVN非0,CPU的总线模式应该从“fast bus mode”变为“asynchronous bus mode” */
mrc p15, 0, r1, c1, c0, 0 /* 读出控制寄存器 */
orr r1, r1, #0xc0000000 /* 设置为“asynchronous bus mode” */
mcr p15, 0, r1, c1, c0, 0 /* 写入控制寄存器 */
后面使能sram
再往后进行代码重定义:
1. 首先建立栈 初始化nandflash
2. 进行代码重定义
ldr sp, = 0x34000000 /*set stack for c language*/
bl nand_init /*initialize the nand flash*/
mov r0, #0
ldr r1, =_start /*get code start address from lds file*/
ldr r2, =__bss_start /*get bss start address from lds file */
sub r2, r2, r1
bl copy_code2sdram /*relocate the text to sdram*/
bl clear_bss
进入主函数 注册 并且跳到内核
/*5. excute main*/
ldr lr, = halt
ldr pc, = main
halt:
b halt
相关文章









