I used the official S32K144 CSEc example to debug.
software:Configure_part_and_Load_keys
chip:FS32K144HAMLL
However, while executing the following statement
The default interrupt is entered,as follow
What is the reason for this?
Thanks!
Hi @feiyiniu
that's weird behavior, this should not happen. Did you execute this project from RAM memory? Do you remember what was returned by configure_part_CSEc() first time? Could you check what is the content of FCFG1 register in SIM module?
Regards,
Lukas
execute this project from flash memory;
configure_part_CSEc() return 160;
FCFG1 register as follow:
Thanks!
First thing is that the project needs to be executed from RAM memory:
Second thing is that the device was already partitioned in the past because the values in FCFG1 do not correspond to configuration used in this example.
Now it depends if CSEc was enabled or not.
If CSEc was not enabled, you can just run mass erase command and then everything should work as expected. To run mass erase, create new empty project in S32DS and add this code:
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) != FTFC_FSTAT_CCIF_MASK); /* Wait until any ongoing flash operation is completed */
FTFC->FSTAT = (FTFC_FSTAT_FPVIOL_MASK | FTFC_FSTAT_ACCERR_MASK); /* Write 1 to clear error flags */
FTFC->FCCOB[3] = 0x49; /* FCCOB0 = 0x49, Erase All Blocks Unsecure command */
FTFC->FSTAT = FTFC_FSTAT_CCIF_MASK; /* Start command execution by writing 1 to clear CCIF bit */
while((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) != FTFC_FSTAT_CCIF_MASK); /* Wait until ongoing flash operation is completed */
It's important to run this project from RAM memory. Then reset the device and check content of FCFG1 again. If DEPART value is changed to 0xF, it's good result. You can start over using 1_Configure_part_and_Load_keys example and it should work now. But as mentioned above, execute the project from RAM.
If CSEc was enabled in the past, you need to know the MASTER_ECU_KEY. Without this key, it is not possible to destroy the partition and then to run mass erase command. The only way to recover is to run CMD_DBG_CHAL and CMD_DBG_AUTH commands with knowledge of MASTER_ECU_KEY. If you don't know the key, I recommend to use new MCU.
Regards,
Lukas
Is there a flag to read whether CSEc enabled?
Thanks!
There's no such flag. If the device is partitioned (you can see this in FCFG1 register), you can check the end of Emulated EERPOM. As mentioned in the AN5401:
If CSEc is enabled, this part of EEE is used as a secure storage NVM, so it's removed from memory map and it's not visible for user at all.
If CSEc is disabled, this area is still accessible.
So, this indirect method can be used.
Regards,
Lukas
I got it, Thanks!