I have a product that includes a firmware upgrade, when running in the field the upgrade will occasionally fail (about 5% of the time), and completely brick the device. I can't see anything obviously wrong so I am going over all the code with a fine tooth comb trying to find what the problem is...
I found a strange issue with the erasing.
When trying to do a mass erase in preparation for the firmware write, for some reason when I run the erase flash block command at address 0x40000 it fails with MGSTAT0 error (i.e. verify failed), but if I erase the block sector-by-sector and manually verify then it is erased and doesn't report any errors.
If I then read out the memory using JTAG Commander following a block erase, the binary file shows the upper block to be correctly erased.
Does anybody have any idea why it is reporting a fail when it is actually working?
The erase all blocks command also fails with a verify error.
Things I have checked:
* All the flash protection registers are 0xFF
* The flash configuration is set to 0xFFFFFFFE
* Watchdog is disabled
* Interrupts are disabled
* The code is running in RAM
* fails whether or not debugger is attached
I'm using a K60N512VLQ10 rev 4N22D