STM32F446.Saving data in flash eeprom-like without using last big sector. Changing .ld file leads to malfunction.
Hi to all the community.
I have to save in non volatile memory some small amount of data,say 200 bytes.
STM32F446 has different sector sizes,
sectors 0,1,2,3 size= 16KB
sectors 4 size= 64KB
sectors 5,6,7 size=128KB
In other microcontrollers i was used to reserve last sector for saving my data.
In this case ,to me it looks a waste to reserve 128KB for such small amount of data.
Despite consecutive savings of data could be spreaded in emulated eeprom mode
and erase could be infrequent ,remains that this sector is no longer available for code.
For this reason i tried to use the first 16KB sector changing at linker level by the .ld file
(I'm using GNU with the good old AC& environment,because my PC is pretty old).
This method always worked using the last sector,but i have malfunction using first sector
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
FLASH (rx) : ORIGIN = 0x8004000, LENGTH = 496K
MyFlashSector (rx) : ORIGIN = 0x8000000, LENGTH = 16K
}
SECTIONS /* Define output sections */
{
.my_block1 0x8000000 :
{
KEEP(*(.MySector))
} >
.....Then in C Code what i do is to declare my constant data
const uint16_t __attribute__((section (".MySector"))) CellsMem [100]={0xA200,0x8400,..and trying to relocate the vector table in the first FLASH sector available
in system_stm32f4xx.c..If not ,not even the systick interrupt happens.
SCB->VTOR = (FLASH_BASE | 0x4000);In this case everything looks working,except that in debug it can't stop and restart from reset.
Is there anyway to correct this last point or everything needs to be changed?
If the topic has yet been posted and developed please,link it and i will delete this question,if it is repetitive.
Thanks
Diego ,
Milan,Italy
