首先说明一下芯片内存情况:片内flash地址为0x00000000,大小为256K,片内sram为0x20000000,大小为64K. 现在想把代码放到SRAM运行,下面给出分散加载文件和编译时的map输出 FLASH 0x00000000 0x00010000 { RESET 0x00000000 0x00010000 { *.o (RESET, +First) } RO +0x20000000 0x00010000 { * (+RO) } RW +0 0x00010000 { * (+RW) } ZI +0 0x00010000 { * (+ZI) } } map输出: ================================================================================
Memory Map of the image
Image Entry point : 0x0000006f
Load Region FLASH (Base: 0x00000000, Size: 0x00000d70, Max: 0x00010000, ABSOLUTE)
Execution Region RESET (Base: 0x00000000, Size: 0x000000d8, Max: 0x00010000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x00000000 0x000000b8 Code RO 159 * RESET bl_startup_rvmdk.o 0x000000b8 0x0000000a Ven RO 178 Veneer$$Code anon$$obj.o 0x000000c2 0x0000000a Ven RO 179 Veneer$$Code anon$$obj.o 0x000000cc 0x0000000a Ven RO 180 Veneer$$Code anon$$obj.o
Execution Region RO (Base: 0x200000d8, Size: 0x00000c34, Max: 0x00010000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x200000d8 0x00000048 Code RO 28 .text bl_check.o 0x20000120 0x00000b90 Code RO 55 .text bl_enet.o 0x20000cb0 0x00000024 Code RO 171 .text memcpya.o(mc_w.l) 0x20000cd4 0x00000026 Code RO 173 .text memseta.o(mc_w.l) 0x20000cfa 0x0000000a Ven RO 181 Veneer$$Code anon$$obj.o 0x20000d04 0x00000006 Data RO 57 .constdata bl_enet.o
Execution Region RW (Base: 0x20000d0c, Size: 0x00000064, Max: 0x00010000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x20000d0c 0x00000064 Data RW 56 .data bl_enet.o
Execution Region ZI (Base: 0x20000d70, Size: 0x0000041c, Max: 0x00010000, ABSOLUTE)
Base Addr Size Type Attr Idx E Section Name Object
0x20000d70 0x0000035c Zero RW 58 .bss bl_enet.o 0x200010cc 0x000000c0 Zero RW 158 .bss bl_startup_rvmdk.o
================================================================================ 一开机就开始运行如下这段代码
ProcessorInit ; ; Copy the code image from flash to SRAM. ; movs r0, #0x00000000 ldr r1, =0x20000000 import ||Image$$ZI$$Base|| ldr r2, =||Image$$ZI$$Base|| copy_loop ldr r3, [r0], #4 str r3, [r1], #4 cmp r1, r2 blt copy_loop
; ; Zero fill the .bss section. ; movs r0, #0x00000000 import ||Image$$ZI$$Limit|| ldr r2, =||Image$$ZI$$Limit|| zero_loop str r0, [r1], #4 cmp r1, r2 blt zero_loop
; ; Set the vector table pointer to the beginning of SRAM. ; ldr r0, =0xe000ed08 ldr r1, =0x20000000 str r1, [r0]
orr lr, lr, #0x20000000 bx lr 在执行这段代码的时候,发现||Image$$ZI$$Limit||的值和||Image$$ZI$$Base||居然是一样的,都为0x20000d70。根据map的输出,这两个值不应该相等啊?
|