Debug S32K144 CSEc example issues

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debug S32K144 CSEc example issues

801 Views
feiyiniu
Contributor II

I used the official S32K144 CSEc example to debug.

software:Configure_part_and_Load_keys

chip:FS32K144HAMLL

However, while executing the following statement

feiyiniu_0-1688000017757.png

  • The default interrupt is entered,as follow

  •  
     
    feiyiniu_3-1688000538116.png
    • What is the reason for this?

    • Thanks!

     

 

0 Kudos
6 Replies

769 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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

0 Kudos

755 Views
feiyiniu
Contributor II

execute this project from flash memory;

configure_part_CSEc() return 160;

FCFG1 register as follow:

feiyiniu_1-1688048277456.png

Thanks!

0 Kudos

743 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

First thing is that the project needs to be executed from RAM memory:

lukaszadrapa_0-1688058247844.png

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

 

0 Kudos

697 Views
feiyiniu
Contributor II

Is there a flag to read whether CSEc enabled?

Thanks!

0 Kudos

690 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

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:

lukaszadrapa_0-1688489340154.png

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

 

0 Kudos

666 Views
feiyiniu
Contributor II

I got it, Thanks!

0 Kudos