2016-01-08 03:24 AM
I have to place some variables at specific address in memory. I'm using GCC.
I declare and use variable like this:uint8_t __attribute__((section (''.mySection''))) buffer = 5;
int main()
{
buffer = 10;
}
And in linker script I've got:
MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 145K MYSEC (xrw) : ORIGIN = 0x20025000, LENGTH = 155K }
and later:
.mySection : { *(.mySection); } > MYSEC
Normally my program takes 22 KB, with this modification it takes 384 MB (!).
I don't understand why. If I remove
__attribute__
it takes 22 KB again. What am I missing?
#memory-sections-ram-linker
2016-01-08 04:10 AM
I don't understand why.
Likely because the RAM section gets correctly managed in the FLASH load region, and MYSEC does not. The .BIN isn't going to be able to represent sparse data, and unless you define MYSEC as uninitialized, or add start up code to unpack it from FLASH, none of this is going to work on a stand alone boot up of the system.2016-01-08 06:17 AM