2016-11-21 07:00 AM
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¤tviews=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.
2016-11-21 08:05 AM
Where does it show userConfig being placed?
I'd use this.eeprom :
{
. = ALIGN(4);
*(.eeprom)
*(.eeprom*)
. = ALIGN(4);
} > DATA
2016-11-21 10:55 AM
Garbage collector probably remove this section.
2016-11-21 03:00 PM
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.