I am using the the NXP MK60FN1M0VLQ12 and I have some variables I want to store in the internal Flash, so I declared a separate section in the linker script and a global struct in it to be referenced by the code. Then to program it I use a slightly modified version of Processor Expert's FMC driver to erase the sector then program 8 bytes at a time.
However, whenever the global variable is declared, I fail to erase/program the flash, and otherwise it works fine. Of course the easy workaround in this case is to use a pointer to the section, but I also plan to rewrite a code section, where this wouldn't work. Does this have to do with the C linker/compiler or is it a MK60 or driver thing?
Here are the concerned code slices:
Linker script:
m_status_page (RX) : ORIGIN = 0x00040000, LENGTH = 0x00001000
.status_page : { . = ALIGN(4); KEEP(*(.STATUS_PAGE)) . = ALIGN(4); } > m_status_page
Global variable declaration:
StatusPage _status_page[TOTAL_STATUS_PAGE_NUMBER] __attribute__ ((section (".STATUS_PAGE")));
Then when I do the execute the following command it does nothing and doesn't throw an error:
flashProgram8Bytes(bytes_to_program, _status_page);
But if I don't declare the _status_page variable for example the following command works:
flashProgram8Bytes(bytes_to_program, 0x00040000);