cancel
Showing results for 
Search instead for 
Did you mean: 

Storing user data in Flash memory

MA SH
Associate
Posted on October 29, 2017 at 14:39

Hello,

I use STM32F401RE Nucleo board and Keil MDK5 IDE. In my application I need to store user data in flash memory.

The sectors implementation in STM32f401 is as following:

Sector 0 0x0800 0000 - 0x0800 3FFF 16 Kbytes

Sector 1 0x0800 4000 - 0x0800 7FFF 16 Kbytes

Sector 2 0x0800 8000 - 0x0800 BFFF 16 Kbytes

Sector 3 0x0800 C000 - 0x0800 FFFF 16 Kbytes

Sector 4 0x0801 0000 - 0x0801 FFFF 64 Kbytes

Sector 5 0x0802 0000 - 0x0803 FFFF 128 Kbytes

Sector 6 0x0804 0000 - 0x0805 FFFF 128 Kbytes

Sector 7 0x0806 0000 - 0x0807 FFFF 128 Kbytes

I need only 32KB for user data. when I used sector 7 in my code, it worked well.

But it is wasting of the memory.

I want to use the smaller first sectors (sectors 0 and 1) for user data and the next sectors for the application.

I edited the scatter file as following but it does not work.

After rebuilding and running, the application does not run from the address 0x8008000. it runs from another addresses and run an old code.  Any Advice???

This is the scatter file

0690X00000608mqQAA.png

I also edited the programming algorithm as following:

0690X00000608mlQAA.png

#stm32-f #stm32f401re #stm32f4-flash-mem
1 REPLY 1
S.Ma
Principal
Posted on October 30, 2017 at 08:29

Find the linker spec to edit the STM32 memory segments addresses and shrink the code one, add your specific sector area for your own use. Otherwise, the linker will fillup the flash area from bottom to top with global constants and code.