Hi,
On my board: CPU LPC2292, external flash SST39VF1601(size 2MB, 16- bit data bus), external RAM IS61LV51216(size 8MB, 16-bit data bus)
-
Is it necessary to load the .data sector, which contains the initialized data, into RAM(internal or external) when the program starts? It seems that I can not change the values of the initialized variables in my program if I do not load the .data section into RAM.
-
I try to load the .data section in the linker script file into SDRAM(external) with the following codes. However, there is something wrong. There are two initialized large-size arrays in my program, exactly two pictures in hex format, and if I do not load them into the SDRAM, I can display them on the LCD correctly. If I load them, it can not.
Please help me to see what the problem is, if any mistake, please correct me. Thank you!
Regards,
Kevin
/* Copy .data setction from ROM to RAM */
ldr r1, =_text_end
ldr r2, =_data_start
ldr r3, =_data_end
loop1: cmp r2, r3
ldrlo r0, [r1], #4
strlo r0, [r2], #4
blo loop1
/* Clear .bss section (zero init) */
mov r0, #0
ldr r1, =_bss_start
ldr r2, =_bss_end
loop2: cmp r1, r2
strlo r0, [r1], #4
blo loop2
/* jump to c language source code */
b main
My linker script file is as follows. the loading data into RAM version. If I do not load the data section, I just replace the .data section with:
.data :
{
_data_start = .;
*(.data)
_data_end = .;
} > FLASH
OUTPUT_FORMAT(“elf32-littlearm”)
OUTPUT_ARCH(arm)
ENTRY(_start)
/* Memory Definitions */
MEMORY
{
FLASH (rx) : ORIGIN = 0x80000000, LENGTH = 0x200000 /* external flash */
DRAM (rwx) : ORIGIN = 0x81000000, LENGTH = 0x800000 /* external DRAM */
SRAM_ISP_LOW(A) : ORIGIN = 0x40000120, LENGTH = 224 /* internal SRAM used by ISP commands */
SRAM (rwx) : ORIGIN = 0x4000200, LENGTH = 0x3D00 /* free internal SRAM */
SRAM_ISP_HIGH(A) : ORIGIN = 0x40003F00, LENGTH = 0x100 /* internal SRAM used by ISP stack */
}
/* define a global symbol _stack_end */
_stack_end = 0x40003CF0;
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
. = 0x80000000;
.text :
{
_text_start = .;
*(.text)
(.rodata) / read-only data (constants) */
(.rodata)
*(.glue_7)
*(.glue_7t)
_text_end = .;
} > FLASH /* assign the above section to Flash */
. = ALIGN(4);
_etext = .;
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data_start = .;
*(.data)
_data_end = .;
} > DRAM
. = ALIGN(4);
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
_bss_start = .;
*(.bss)
*(COMMON)
_bss_end = .;
} > DRAM
. = ALIGN(4);
_end = . ;
PROVIDE (end = .);
}