Dear Ping,
BOARD I
I'm in big trouble now :smileysad:, yet to hear the root cause of this issue from you. I cannot do much debugging on this board, I would suggest NXP to debug this board and find out the root cause. I've worked with many Silicon vendors (TI, Cypress, NXP ..) but never experienced FW image corruption inside MCU flash. This is rare. How can I go for mass production with this controller?
BOARD II
From further debugging on the second board using Segger command line utility shows that the Flash got secured and
Mass erase is disabled. This is the worst situation, as per Reference manual the only way to recover the board is by Silicon replacement. Please find the below text copied from Device Reference manual (K22F Sub-Family Reference Manual , Rev. 3, 7/2014 ).
9.13 Debug & Security
When security is enabled (FSEC[SEC] != 10), the debug port capabilities are limited in order to prevent exploitation of secure data. In the secure state the debugger still has access to the MDM-AP Status Register and can determine the current security state of the device. In the case of a secure device, the debugger also has the capability of performing a mass erase operation via writes to the MDM-AP Control Register. In the case of a secure device that has mass erase disabled (FSEC[MEEN] = 10), attempts to mass erase via the debug interface are blocked.
It looks like this issue is common in K22F controller as I'm seeing same issue in two of my custom boards also. Please find the error message from OpenOCD below,
Error: Cannot access device, device is secured
Info : Mass erasing a device will unsecure it until the next reset. To permanently unsecure, mass erase then flash a program containing an appropriate flash configuration field.
Please escalate this issue. My mass production is getting delayed due to this issue. I cannot go ahead with this controller unless I get proper clarification from NXP team.
Thanks,
Prajith