Using ARM clang / linker ver 6.2 I am trying to put a variable in unitialised rw memory, so that it does not get zeroed at reset.
Does anyone have any example of how to do this? the example shown below gets zeroed on reset
I have tried defining sections in the scatter file and then attribute in 'C' module -
static volatile measurement_entry_t measurement_queue[MAX_STORE_MEASUREMENTS] __attribute__((section(".mstore"),aligned(4), used));
Can anyone detail how i may add this to the scatter file which at my last attempt is -
LR_IROM1 0x08000000 0x00100000 { ; load region size_region ER_IROM1 0x08000000 0x00100000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) } RW_IRAM1 0x20000000 0x000B0000 { ; RW data .ANY (+RW +ZI) } ER_MEASURE_DATA 0x200B0000 UNINIT 0x00010000 { ; 64K unitialised space .ANY(.mstore) }}
Hi David,
The UNINIT attribute only affects Zero-Initialized (ZI) data:
https://developer.arm.com/documentation/101754/0623/armlink-Reference/Scatter-File-Syntax/Execution-region-descriptions/Execution-region-attributes
It is hard to determine from your description, but is measurement_queue[] being located at 0x200b0000 successfully?
You may need to be more specific with your object naming than using .ANY as a catch-all.
ER_MEASURE_DATA 0x200B0000 UNINIT 0x00010000 { ; 64K unitialised space object_name.o (.mstore, +ZI) }
Yes the measurement_queue is located successfully but zeroed at startup which happens in the call to __main. I think that I may need to manual modify the initialisation code to prevent it zeroing the section. Not sure where to find the memory init code, I guess this is part of the Keil C libs?
Further to this I have found (suggested by Hitex) that ignoring sections and putting the variable allocation in a separate C file with nothing else then putting the C obj file in a region. ie - ; Non-initialized section at top of RAM RW_meas_store 0x200B0000 UNINIT 0x00010000 { mstore_mem.o(+ZI +RW) }
where mstore_mem.c only has the variable allocated.