Hi @HSByun
as I can see on the first screenshot, the device is already partitioned but in different way than what is configured in S32K144_Memory_Partition_Debug_RAM. This example configures:
FTFC->FCCOB[6] = 0x0A; /* FCCOB5 = 0x0A, 16K data flash, 48k EEPROM backup */
But I can see in FCFG1 that whole FlexNVM is already allocated for EEPROM backup flash. So, someone obviously already enabled the Emulated EEPROM and maybe also CSEc on this device.
Step 1: Try to run mass erase (Erase All Blocks Unsecure command). You can add this code to project S32K144_Memory_Partition, to function configure_part_CSEc() before running partition comnmand:
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 */
flash_error_status = FTFC->FSTAT; /* Read the flash status register for any Execution Error */
If it is successful, it should work now. If not, the CSEc was obviously enabled. To remove the partition, you need to know MASTER_ECU_KEY. If you don't know it, you need to use new device.
In case that example projects from application note AN5401 or from SDK were used, you can try to run:
1. 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
2. This project from SDK:
c:\NXP\S32DS.3.4\S32DS\software\S32SDK_S32K1XX_RTM_4.0.2\examples\S32K144\driver_examples\system\csec_keyconfig\
... with this macro set to '1':
/* Set this macro-definition to 1 if you want to reset all the keys */
#define ERASE_ALL_KEYS 1
If one of these projects was used in the past with no modification of MASTER_ECU_KEY then this will disable the CSEc, so you can start over. If you are not successful with this, it will be necessary to use new device.
Regards,
Lukas