volatile const
I need to declare a 'volatile const', meaning that the value is placed in FLASH and that it is re-read every time it is referenced (as the FLASH is written to elsewhere), but am finding it very difficult to accomplish this as the compiler either places this in RAM or optimises it so that the FLASH is not read every time.
volatile const uint8_t mcau8VT_SP_Backup[] __attribute__((aligned(4))) = {0xFF, 0xFF, 0xFF, 0xFF};The compiler gives this a 'Run Address (VMA)' of 0x20000000 (i.e. RAM) and a 'Load Address (LMA)' in FLASH.
const uint8_t mcau8VT_SP_Backup[] __attribute__((aligned(4))) = {0xFF, 0xFF, 0xFF, 0xFF};In this case the 'Run Address (VMA)' is in FLASH but the compiler "optimises" things so that the value is not read from FLASH every time and does not update when the FLASH is written to.
I have tried every combination of suggestions which I can find online including adding an attribute trying to specify which section the const should go in (.rodata), adding additional const keywords so that the "pointer" is const as well (and not just the "data"), and placing the consts in an external file.
How can I get this to be placed in FLASH and re-read every time, so that it sees updates made to the FLASH elsewhere?
