cancel
Showing results for 
Search instead for 
Did you mean: 

Issue placing constants in flash

nkskjames
Associate
Posted on November 21, 2016 at 16:00

I'm following the post on[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/How%20to%20allocate%20variable%20in%20Flash%20to%20desired%20address&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=7799]ST Forum, to place constants in flash of an STM32F I have this in .c file:

__attribute__((__section__(''.eeprom''))) const uint8_t userConfig[16384];

I have this in .ld file:

MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K - 16K
DATA (rx) : ORIGIN = 0x803C000, LENGTH = 16K
}

.eeprom :

{
. = ALIGN(4);
*(.eeprom)
. = ALIGN(4);
} > DATA

But in the .map file, it doesn't show it placing variable:

eeprom 0x0803c000 0x0
0x0803c000 . = ALIGN (0x4)
*(.eeprom)
0x0803c000 . = ALIGN (0x4)

I would expect to see non-zero size and name of const here. Please help.
3 REPLIES 3
Posted on November 21, 2016 at 17:05

Where does it show userConfig being placed?

I'd use this

.eeprom :
{
. = ALIGN(4);
*(.eeprom)
*(.eeprom*)
. = ALIGN(4);
} > DATA

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Radosław
Senior
Posted on November 21, 2016 at 19:55

Garbage collector probably remove this section.

nkskjames
Associate
Posted on November 22, 2016 at 00:00

Yes, that was the case.   I also had to remove the const since I want to update the flash behind the scenes and have the variable reflect it.