I am trying to store data in flash memory on a STM32F411VET6. I want the memory to store and stay there even after rebooting the MC. I have looked at this, this, this and this examples but I am still not sure that I am doing this correctly. I was able to create a location in memory (I checked in the map file) with this as my scatter file:
LR_IROM1 0x08000000 0x00080000 { ; load region size_region
ER_IROM1 0x08000000 0x00060000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
.ANY (+XO)
}
USER_CONFIG 0x08060000 0x0001FFFF {
userConfig.o (+RW)
}
RW_IRAM1 0x20000000 0x00020000 { ; RW data
.ANY (+RW +ZI)
}
}
and this for my code (adapted from this example):
__attribute__((__section__("USER_CONFIG"))) const char userValues[64];
void Write_Flash(uint32_t data[], uint8_t flashTypeProgram)
{
uint8_t addressGap;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGSERR);
FLASH_Erase_Sector(FLASH_SECTOR_7, VOLTAGE_RANGE_3);
int ii = 0;
for (ii = 0; ii < 64 / pow(2, flashTypeProgram); ii++)
{
addressGap = pow(2, flashTypeProgram) * ii;
HAL_FLASH_Program(flashTypeProgram, userValues[0] + addressGap, data[ii]);
}
HAL_FLASH_Lock();
}
but whenever I build the code I get an error that "No section matches pattern userConfig.o".
Is there anything that I am setting up incorrectly or why if I am missing a call somewhere?