Hi,
Important point is that once the CSE is enabled, mass erase cannot be executed. To be able to mass erase the flash, it’s necessary to reset the chip back to factory state using CMD_DBG_CHAL and CMD_DBG_AUTH commands. For this operation, you need to know MASTER_ECU_KEY.
There are following reasons why the chip is (or seems to be) bricked:
- if your debugger uses mass erase when loading new project to flash, it won’t work due to reasons described above. Some debuggers erase individual blocks instead of performing mass erase, so this works. But you should be still able to establish the connection via JTAG/SWD and you should be able to load a project to RAM memory.
- if you enabled strict sequential boot mode and the flash content does not corresponds to calculated CMAC. In this case, the chip will never leave reset state and it cannot be recovered.
So, my recommendation is to check if the reset signal is asserted all the time and if you are able to enter debug mode via JTAG/SWD.
To destroy the partition / disable CSE, you can use project 5_Resetting_flash_to_the_factory_state from AN5401:
https://www.nxp.com/webapp/Download?colCode=AN5401&location=null
https://www.nxp.com/webapp/Download?colCode=AN5401SW&location=null
Notice that it needs to be executed from RAM and it is necessary to update your MASTER_ECU_KEY in file CSEc_functions.c, function DBG_AUTH. Change this as needed and run the project:
uint32_t MASTER_ECU_KEY_VALUE[4] = {0xD275F12C, 0xA863A7B5, 0xF933DF92, 0x6498FB4D};
Then mass erase should work and it should be possible to load new project to the flash.
Regards,
Lukas