cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F769 Flash Memory Allocation for user data

THIHA KYAW
Associate III
Posted on January 19, 2018 at 03:33

Hi,

Flash memory address is from ADDR_FLASH_SECTOR_0 to ADDR_FLASH_SECTOR_23.

Which sectors are for program code?

How to choose flash sector to store user data?

Please advise me.

Thanks.

Regards,

Thiha Kyaw

#stm32f769 #flash
1 REPLY 1
Mario Popovic_2
Associate II
Posted on January 19, 2018 at 08:42

Hi,

that depends on your linker script. By default all the flash memory is used for code and data. By 'user data' I suppose you mean something like user configuration that should be stored and not changed when reprogrammed by code. In that case you should select one or more of the sectors and modify the linker script. I usually use the last section for that, in your case that would be 

ADDR_FLASH_SECTOR_23.

First you modify the linker script to add new section. Something like this:

/* Specify the memory areas */

MEMORY

{

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768k

USER_SETTINGS (ra) : ORIGIN = 0x080C0000, LENGTH = 256K

}

Notice that you have to reduce the size of 'FLASH' section since you're taking space from it. Also this section should start at ADDR_FLASH_SECTOR_x that you choose.

Second, yo specify which data to put in it by placing:

.user_settings_section (NOLOAD):

{

. = ALIGN(4);

KEEP(*(.user_settings_section)) /* Config section */

. = ALIGN(4);

} >USER_SETTINGS

The 'NOLOAD' argument will tell linker that this section data should not be put into ELF file which means it will not be programmed when updating the code.

Third you need to let the compiler know which code to put into this section by using __attribute_(section). For example:

static volatile const userSettingsType userSettingsFlash __attribute__((used)) __attribute__((section('.user_settings_section')));

Hope this helps

Regards,

Mario