S32K144 CSEc Error

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

S32K144 CSEc Error

Jump to solution
785 Views
Jason88619
Contributor II

Hello, I am using the CSEc of the S32K144 chip. I use the S32K1xx CSEC Tool to generate an initialization binary file for the CSEc module, and download the initialization file into the S32K144 chip via J-link. Then I run my own program, and a Reset_Handler occurs at CSEC_DRV_InitRNG. Why is this happening? Did I set something wrong? The pictures below show some of my code and configurations.

Jason88619_0-1762250148114.png

Jason88619_1-1762250165059.png

Jason88619_2-1762250205472.png

0 Kudos
Reply
1 Solution
666 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I did quick test on my board and it works as expected - I can enable CSEc by "Initial Firmware", then the CSEc works as expected and then I can reset the device by "Reset Firmware". But I noticed one difference: using the same configuration, DEPART is set 0x04 by the firmware. If I click on "Create Partition Code" in the tool, it is also showing 0x04:

lukaszadrapa_0-1762521030560.png

But your screenshot shows that the DEPART is 0x08. It looks like the device is already partitioned but CSEc is not enabled. 

I can see it's not explicitly mentioned in the user manual of the tool, but I supposed that it expects that the partition is not set when running "Initial Firmware".

I would try to create RAM project and just run FLASH_DRV_EraseAllBlockUnsecure command. Not just FLASH_DRV_EraseAllBlock command because then it would be necessary to program flash configuration field to unsecured state. 

I believe that it will work as expected after such mass erase. 

Regards,

Lukas

View solution in original post

0 Kudos
Reply
6 Replies
707 Views
Jason88619
Contributor II

As you mentioned, I checked my FCFG1 register and FCSESTAT register, but their values showed no changes before the program entered the Reset_Handle 。According to the FCFG1 register, the EEPROM memory has been allocated. However, I executed the Reset program generated by the S32K1xx CSEc Tool (though it may not have executed successfully). From the FCSESTAT register, the status of CSEc remains "Busy", even though no operations are currently being performed on CSEc. What should I do to restore CSEc to normal?

Jason88619_1-1762481705476.png

 

Jason88619_0-1762481652877.png

 

Best regard,

Jason

0 Kudos
Reply
667 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I did quick test on my board and it works as expected - I can enable CSEc by "Initial Firmware", then the CSEc works as expected and then I can reset the device by "Reset Firmware". But I noticed one difference: using the same configuration, DEPART is set 0x04 by the firmware. If I click on "Create Partition Code" in the tool, it is also showing 0x04:

lukaszadrapa_0-1762521030560.png

But your screenshot shows that the DEPART is 0x08. It looks like the device is already partitioned but CSEc is not enabled. 

I can see it's not explicitly mentioned in the user manual of the tool, but I supposed that it expects that the partition is not set when running "Initial Firmware".

I would try to create RAM project and just run FLASH_DRV_EraseAllBlockUnsecure command. Not just FLASH_DRV_EraseAllBlock command because then it would be necessary to program flash configuration field to unsecured state. 

I believe that it will work as expected after such mass erase. 

Regards,

Lukas

0 Kudos
Reply
596 Views
Jason88619
Contributor II
As you suspected, the CSEC_DRV_InitRNG function executed successfully after FLASH_DRV_EraseAllBlockUnsecure. Although for some unknown reason a HardFault occurred during the execution of FLASH_DRV_EraseAllBlockUnsecure, the function subsequently completed successfully. After that, the CSEc was able to initialize normally.
Thank you very much for your explanations and help.Wishing you happiness every single day!
 
Best Regards,
Jason
0 Kudos
Reply
731 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Jason88619 

CSE PRAM is not writeable if the device is not partitioned and if CSEc is not enabled. This was discussed here, for example:

https://community.nxp.com/t5/S32K/CSE-PRAM-is-not-writable-S32K146/td-p/1282095

Was the InitFW loaded and executed successfully? What can you see in FCFG1 register in SIM module?

Regards,

Lukas

0 Kudos
Reply
704 Views
Jason88619
Contributor II

Inside the CSEC_DRV_InitRNG function, immediately after executing the line

/* Write the command header. This will trigger the command execution. */
CSEC_WriteCommandHeader(CSEC_CMD_INIT_RNG, CSEC_FUNC_FORMAT_COPY

/* Write the command header. This will trigger the command execution. */ CSEC_WriteCommandHeader(CSEC_CMD_INIT_RNG, CSEC_FUNC_FORMAT_COPY CSEC_CALL_SEQ_FIRST, CSEC_SECRET_KEY); the program enters DefaultISR.

Jason88619_0-1762482730670.png

 

0 Kudos
Reply
730 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

... and also please check FCSESTAT register in FTFC module. 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2198235%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2198235%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHello%2C%20I%20am%20using%20the%20CSEc%20of%20the%20S32K144%20chip.%20I%20use%20the%20S32K1xx%20CSEC%20Tool%20to%20generate%20an%20initialization%20binary%20file%20for%20the%20CSEc%20module%2C%20and%20download%20the%20initialization%20file%20into%20the%20S32K144%20chip%20via%20J-link.%20Then%20I%20run%20my%20own%20program%2C%20and%20a%20Reset_Handler%20occurs%20at%20CSEC_DRV_InitRNG.%20Why%20is%20this%20happening%3F%20Did%20I%20set%20something%20wrong%3F%20The%20pictures%20below%20show%20some%20of%20my%20code%20and%20configurations.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jason88619_0-1762250148114.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jason88619_0-1762250148114.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F363921iB18391C6A5F728A9%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jason88619_0-1762250148114.png%22%20alt%3D%22Jason88619_0-1762250148114.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jason88619_1-1762250165059.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jason88619_1-1762250165059.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F363922i704245E3D9930F59%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jason88619_1-1762250165059.png%22%20alt%3D%22Jason88619_1-1762250165059.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jason88619_2-1762250205472.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jason88619_2-1762250205472.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F363923i6012E793FAF00BE9%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jason88619_2-1762250205472.png%22%20alt%3D%22Jason88619_2-1762250205472.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2201384%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2201384%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CDIV%20class%3D%22%22%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F37795%22%20target%3D%22_blank%22%3E%40lukaszadrapa%3C%2FA%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3EAs%20you%20suspected%2C%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ECSEC_DRV_InitRNG%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efunction%20executed%20successfully%20after%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFLASH_DRV_EraseAllBlockUnsecure.%20Although%20for%20some%20unknown%20reason%20a%20HardFault%20occurred%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eduring%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ethe%20execution%20of%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFLASH_DRV_EraseAllBlockUnsecure%2C%20the%20function%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esubsequently%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecompleted%20successfully.%20After%20that%2C%20the%20CSEc%20was%20able%20to%20initialize%20normally.%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3EThank%20you%20very%20much%20for%20your%20explanations%20and%20help.%3CSPAN%3EWishing%20you%20happiness%20every%20single%20day!%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3EBest%26nbsp%3B%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%3CSPAN%3EJason%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2200878%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2200878%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20did%20quick%20test%20on%20my%20board%20and%20it%20works%20as%20expected%20-%20I%20can%20enable%20CSEc%20by%20%22Initial%20Firmware%22%2C%20then%20the%20CSEc%20works%20as%20expected%20and%20then%20I%20can%20reset%20the%20device%20by%20%22Reset%20Firmware%22.%20But%20I%20noticed%20one%20difference%3A%20using%20the%20same%20configuration%2C%20DEPART%20is%20set%200x04%20by%20the%20firmware.%20If%20I%20click%20on%20%22Create%20Partition%20Code%22%20in%20the%20tool%2C%20it%20is%20also%20showing%200x04%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22lukaszadrapa_0-1762521030560.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22lukaszadrapa_0-1762521030560.png%22%20style%3D%22width%3A%20263px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F364461i5CCF7239DB9723D7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22lukaszadrapa_0-1762521030560.png%22%20alt%3D%22lukaszadrapa_0-1762521030560.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBut%20your%20screenshot%20shows%20that%20the%20DEPART%20is%200x08.%20It%20looks%20like%20the%20device%20is%20already%20partitioned%20but%20CSEc%20is%20not%20enabled.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20can%20see%20it's%20not%20explicitly%20mentioned%20in%20the%20user%20manual%20of%20the%20tool%2C%20but%20I%20supposed%20that%20it%20expects%20that%20the%20partition%20is%20not%20set%20when%20running%20%22Initial%20Firmware%22.%3C%2FP%3E%0A%3CP%3EI%20would%20try%20to%20create%20RAM%20project%20and%20just%20run%26nbsp%3BFLASH_DRV_EraseAllBlockUnsecure%20command.%20Not%20just%26nbsp%3BFLASH_DRV_EraseAllBlock%20command%20because%20then%20it%20would%20be%20necessary%20to%20program%20flash%20configuration%20field%20to%20unsecured%20state.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20believe%20that%20it%20will%20work%20as%20expected%20after%20such%20mass%20erase.%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2200446%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2200446%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EInside%20the%20CSEC_DRV_InitRNG%20function%2C%20immediately%20after%20executing%20the%20line%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%2F*%20Write%20the%20command%20header.%20This%20will%20trigger%20the%20command%20execution.%20*%2F%0ACSEC_WriteCommandHeader(CSEC_CMD_INIT_RNG%2C%20CSEC_FUNC_FORMAT_COPY%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%3E%2F*%20Write%20the%20command%20header.%20This%20will%20trigger%20the%20command%20execution.%20*%2F%20CSEC_WriteCommandHeader(CSEC_CMD_INIT_RNG%2C%20CSEC_FUNC_FORMAT_COPY%20CSEC_CALL_SEQ_FIRST%2C%20CSEC_SECRET_KEY)%3B%20the%20program%20enters%20DefaultISR.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jason88619_0-1762482730670.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jason88619_0-1762482730670.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F364355iB0EE70D8DC865C17%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jason88619_0-1762482730670.png%22%20alt%3D%22Jason88619_0-1762482730670.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2200433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2200433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EAs%20you%20mentioned%2C%20I%20checked%20my%20FCFG1%20register%20and%20FCSESTAT%20register%2C%20but%20their%20values%20showed%20no%20changes%20before%20the%20program%20entered%20the%20Reset_Handle%20%E3%80%82According%20to%20the%20FCFG1%20register%2C%20the%20EEPROM%20memory%20has%20been%20allocated.%20However%2C%20I%20executed%20the%20Reset%20program%20generated%20by%20the%20S32K1xx%20CSEc%20Tool%20(though%20it%20may%20not%20have%20executed%20successfully).%20From%20the%20FCSESTAT%20register%2C%20the%20status%20of%20CSEc%20remains%20%22Busy%22%2C%20even%20though%20no%20operations%20are%20currently%20being%20performed%20on%20CSEc.%20What%20should%20I%20do%20to%20restore%20CSEc%20to%20normal%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jason88619_1-1762481705476.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jason88619_1-1762481705476.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F364350iACA57A1FC4759961%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jason88619_1-1762481705476.png%22%20alt%3D%22Jason88619_1-1762481705476.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jason88619_0-1762481652877.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jason88619_0-1762481652877.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F364347i99B4728D0CA56F7E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jason88619_0-1762481652877.png%22%20alt%3D%22Jason88619_0-1762481652877.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%3EBest%20regard%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EJason%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2199068%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2199068%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E...%20and%20also%20please%20check%20FCSESTAT%20register%20in%20FTFC%20module.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2199066%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K144%20CSEc%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2199066%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F252822%22%20target%3D%22_blank%22%3E%40Jason88619%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECSE%20PRAM%20is%20not%20writeable%20if%20the%20device%20is%20not%20partitioned%20and%20if%20CSEc%20is%20not%20enabled.%20This%20was%20discussed%20here%2C%20for%20example%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FCSE-PRAM-is-not-writable-S32K146%2Ftd-p%2F1282095%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FCSE-PRAM-is-not-writable-S32K146%2Ftd-p%2F1282095%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EWas%20the%20InitFW%20loaded%20and%20executed%20successfully%3F%26nbsp%3BWhat%20can%20you%20see%20in%20FCFG1%20register%20in%20SIM%20module%3F%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E