Skip to main content
nkskjames
Associate
November 21, 2016
Question

Issue placing constants in flash

  • November 21, 2016
  • 3 replies
  • 772 views
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.
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    November 21, 2016
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    Radosław
    Associate II
    November 21, 2016
    Posted on November 21, 2016 at 19:55

    Garbage collector probably remove this section.

    nkskjames
    nkskjamesAuthor
    Associate
    November 21, 2016
    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.