裸机程序怎么复制到SDRAM中运行,类似U-BOOT
我用的9260,板子上只有NAND FLASH,没有NOR FLASH,64M SDRAM。
bootloader用的 AT91Bootstrap,用SAM-BA烧至NAND FLASH中,再用SAM-BA烧U-BOOT
启动U-BOOT可以把我的裸机程序下载到SDRAM中运行。
现在我想只用SAM-BA烧 AT91Bootstrap,然后把裸机程序烧在U-BOOT在NAND FLASH位置,不用U-BOOT了
但裸机程序启动代码中就要加 复制自身到SDRAM中,类似U-BOOT中:
relocate:
/* relocate U-Boot to RAM
*/
adr
r0, _start
/* r0 <- current position of code */
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 <- size of armboot */
add
r2, r0, r2
/* r2 <- source end address */
copy_loop:
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
但U-BOOT中是怎么知道程序的结束地址 _bss_start???
U-BOOT中运行这段复制代码的时候还是NAND FLASH中读取吗? |