AnsweredAssumed Answered

Storing user data in Flash memory

Question asked by MA SH on Oct 29, 2017
Latest reply on Oct 30, 2017 by KIC8462852 EPIC204278916

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


I also edited the programming algorithm as following: