I'm working writing a custom bootloader for a MK20FN1MVMD12, but I'm running into an issue when I erase block 0. After erasing the entire block by successively calling the erase sector command, any software reads to an address in block 0 results in reading the previous value (not 0xFF). No error is being reported, and the "read 1s section" command indicates that everything was erased properly.
Some potentially important information:
- This only happens when I erase block 0.
- I read the data by doing something like "data = ( ( volatile uint32 * )0x00000000 )[ offset ]" where offset is a value < ( block size / 4 ).
- I am executing out of RAM while performing the erase.
- The FTFE is unsecure at all times during this process.
- If I attempt to write >= 0xC1 bytes after erasing the block, I am able to read properly, but no data is actually written at that point. Any subsequent write calls complete as expected.
- If I use a debugger to look at the erased block, I see that everything was erased, and all subsequent reads in my code work properly.