考虑到nor flash价格,商用版一般只使用nand flash和SDRAM,板子上电后代码从nand flash复制4k到片内ram执行。当代码大于4k时,需要将代码移动到更大的ram即SDRAM中。
本实验实现将代码从SRAM复制到SDRAM。使用DRAM需要初始化相应13个寄存器。
代码段:
head.s:
.equ MEM_CTL_BASE, 0x48000000
.equ SDRAM_BASE, 0x30000000
.text
.global _start
_start:
bl disable_watch_dog
bl memsetup
bl copy_steppingstone_to_sdram
ldr pc, =on_sdram
on_sdram:
ldr sp, =0x34000000
bl main
halt_loop:
b halt_loop
disable_watch_dog:
mov r1, #0x53000000
mov r2, #0x0
str r2, [r1]
mov pc, lr
copy_steppingstone_to_sdram:
mov r1, #0
ldr r2, =SDRAM_BASE
mov r3, #4*1024
1:
ldr r4, [r1],#4
str r4, [r2],#4
cmp r1, r3
bne 1b //b:向后跳,f:向前跳
mov pc, lr
memsetup:
mov r1, #MEM_CTL_BASE
adrl r2, mem_cfg_val
add r3, r1, #52
1:
ldr r4, [r2], #4
str r4, [r1], #4
cmp r1, r3
bne 1b
mov pc, lr
.align 4 //4字节对齐
mem_cfg_val:
.long 0x22011110 @ BWSCON
.long 0x00000700 @ BANKCON0
.long 0x00000700 @ BANKCON1
.long 0x00000700 @ BANKCON2
.long 0x00000700 @ BANKCON3
.long 0x00000700 @ BANKCON4
.long 0x00000700 @ BANKCON5
.long 0x00018005 @ BANKCON6
.long 0x00018005 @ BANKCON7
.long 0x008C07A3 @ REFRESH
.long 0x000000B1 @ BANKSIZE
.long 0x00000030 @ MRSRB6
.long 0x00000030 @ MRSRB7
阅读(254) | 评论(0) | 转发(0) |