Placing an initialized array into internal flash sector
I would like to place an initialized DWORD array at the the beginning of an internal flash sector to access the variables later on at a known address.
The array is
DWORD JumpTable[16] __attribute__ ((section(".jptable"))) = {
(DWORD) CalcComplement,
(DWORD) InitBootLd
};
with the following lines in the flash placement file
<MemorySegment name="BOOTLD">
<ProgramSection alignment="4" load="Yes" inputsections="*(.textbl .textbl.*)" name=".textbl"/>
<ProgramSection alignment="4" load="Yes" inputsections="*(.jptable .jptable.*)" name=".jptable"/>
</MemorySegment>
where BOOTLD is sector 27 of the internal flash (LPC2468):
<MemorySegment start="0x0007D000" size="0x1000" access="ReadOnly" name="BOOTLD"/>
I expected JumpTable[] to be at address 0x7D000, but it is always at 0.
What would be the right way to place the array at 0x7D000?
-
What you've done looks fine.
I've just tried doing what you described here and it works OK - looking at the symbol browser, a section named .jptable is created at 0x0007d000, it is 64 bytes in length and it contains JumpTable.
The only thing I did differently to you was to add the following before the JumpTable definition so that it would build:
typedef unsigned int DWORD;
#define CalcComplement 0
#define InitBootLd 1How are you determining the array is at 0x0000000?
-
To determine that the array is at 0x00000000 I loaded the file and displayed the array using a watch window.
Looking at the symbol browser there is no .jptable section at all when the configuration ARM FLASH Debug is used.
Using the configuration ARM RAM Debug, section and array are placed in the expected SDRAM segment. It looks as if some settings in the FLASH configuration might be responsible!?
-
Thank you Jon for your trouble!
The reason for not creating that section and array was the property ENABLE UNUSED SYMBOL REMOVAL. It had to set to NO.
After swapping the ProgramSection lines like this
<MemorySegment name="BOOTLD">
<ProgramSection alignment="4" load="Yes" inputsections="*(.jptable .jptable.*)" name=".jptable"/>
<ProgramSection alignment="4" load="Yes" inputsections="*(.textbl .textbl.*)" name=".textbl"/>
</MemorySegment>
JumpTable[] has been placed to the desired address 0x7D000.
Now the resulting question is whether there still is a way to benefit from the features that ENABLE UNUSED SYMBOL REMOVAL normally would provide. I mean the reduced storage can be quite remarkable.
Please sign in to leave a comment.
Comments
4 comments