CSEc Working Issues with S32K144 MCU

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

CSEc Working Issues with S32K144 MCU

135 Views
Kunal_Gettobyte
Contributor II

I am using the S32K144 Microcontroller and wanted to use the Hardware Security Module CSEc, but I am not able to Use it. Below is the chronology of events and their results. After this, I am not able to connect to S32K144 MCU via S32 Design STuido, Jlink Flash, Jlink Flash Lite, or Jlink Commander.

1) To use the CSEc I use one of the provided examples in S32K SDK: csec_keyconfig_s32k144 using S32 Design Studio. At first, I built this example code and ran it via Debug Flash configuration.

Results: Communication between the Debugger and MCU is established, I can do debugging in S32DS, but my application fails during CSEc Memory Initialization, because I am using FLASH configuration, as shown in the picture:

Kunal_Gettobyte_0-1700196689271.png

Outcome: I decided to rerun the same demo application but now with a Debug RAM configuration. As it is stated in the above picture if we are using CSEc the first time then we have to, do that by Debug RAM configuration

2) Rerun the SDK demo example: csec_keyconfig_s32k144, but with Debug RAM configuration.

Result: Communication between the Debugger and MCU is established, I can do debugging in S32DS, and this time my application also successfully runs, with no errors. I can step into the main and can see encrypted plaintext in variables:

Outcome: I concluded that now my Csec Operations and commands can be run, as my CSEc is configured and initialized. The EEROM partitioning is done and now i can use CSEc HSM to make my applications.

3) Rerun the SDK demo example: csec_keyconfig_s32k144, but with Debug RAM configuration. Now to understand the code base and expect it will run successfully as it runs in 2nd point.

Result: Communication between the Debugger and MCU is established, I can do debugging in S32DS, but this time demo application returns an error, in setAuthKey() with an error code 0x408(Key update did not succeed due to errors in
verification of the messages ) at line number 193. Below is the picture attached.

Kunal_Gettobyte_1-1700197323829.png

Outcome: Demo Application now always returns with error code 0x408 in setAuthKey(), even though i have not changed any code. So now I thought of rerunning the demo application but with Debug Flash configuration, as in initFlashForCsecOperation, it is stated that when running the first time CSEc we have to do that by RAM only not after that:

Kunal_Gettobyte_2-1700197593889.png

4) rerunning the demo application  csec_keyconfig_s32k144,  with Debug Flash configuration. (In this case, I have done the Csec Memory configuration and initialization in my 2nd step)

Result: My application is not starting, even though the debugger(Jlink) can communicate with S32K144, but the demo application  csec_keyconfig_s32k144, is not getting flashed in the Microcontroller. I tried with S32 Design Studio, Jlink Flash, and Jlink Flash Lite.  Below attached are the photos of what I get with each of the tools

Outcome: I thought that there were some memory configuration issues, so I thought of erasing the chip. As my debugger and Microcontroller S32K144 can communicate using the Jlink Flash tool, I decided to erase the chip S32K144( Mass erase)

5) I did the mass erase, and it happened successfully, using the Jlink Flash tool. Before mass erasing, I did erase all sectors and then Erase Chip.

Result: Mass Erase is done successfully. Now I think my Csec memory Partitioning is also erased/removed from Flash.

Outcome: Now I thought of re-connecting my MCU S32K144 and Debugger via the Jlink Flash tool and flashing a simple hello world example into the microcontroller. 

6) I am not able to establish communication between S32K144 MCU and the debugger, I always get the error:

Kunal_Gettobyte_3-1700198446153.png

Also in S32 Design Studio if I run the hello world application with debug flash configuration, I get the error:

Kunal_Gettobyte_4-1700198490559.png

Now after 5th step, I am not able to communicate with MCU S32K144 and every time I get an error as shown in step 6. 

Is my chip bricked? I tried everything resetting the RST pin to low externally and then trying to connect.

  • I wanna know which step above should have not been done and which is wrong.
  • And what should I now do to connect back to the MCU S32K144? after step 5

I wanna know what chronological steps should one follow to use CSEc HSM in their application, as I can't find chronological and correct steps for doing so. As in Step 2, I got my CSEc working, but if I rerun the same application it demo application starts giving errors without changing any code. After that, I performed chip erase to erase the flash but that made it worse, as now I am not even able to communicate with Microcontroller S32K144. 

Tags (2)
0 Kudos
0 Replies