MPC5777C CSE Problem

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5777C CSE Problem

Jump to solution
596 Views
jeffcampbell
Contributor III

Well, I'm back again.  I think I've messed up my CSE - directly from the system reset, it has an error code 0x13 (error reading, programming, or erasing one of the CSE flash blocks).  I decided to try and follow the instructions for resetting its flash space, but these involve working through the CSE itself, and any CSE commands I issue are ignored and it throws a 0x02 error code (command sequence error).  No combination of CANCEL and INIT_CSE commands worked.  CANCEL is the only command the CSE will accept without throwing that 0x02 error.

 

I've tried looking through AN4234, but a lot of details seem to be outdated for the MPC5777C.

 

Any thoughts as to what might be wrong?

Labels (1)
Tags (2)
0 Kudos
1 Solution
231 Views
jeffcampbell
Contributor III

False alarm everyone; nothing to see here.  It turns out that MULTI was optimizing away some important variables there (namely, 'final') because they were local variables and were not directly reference later in the program.  Making these variables global fixed everything.

View solution in original post

0 Kudos
3 Replies
232 Views
jeffcampbell
Contributor III

False alarm everyone; nothing to see here.  It turns out that MULTI was optimizing away some important variables there (namely, 'final') because they were local variables and were not directly reference later in the program.  Making these variables global fixed everything.

View solution in original post

0 Kudos
231 Views
tong_zhou
Contributor I

hi, Jeff:

    now i meet the same issue. when i completed erasing all keys, in debug mode, I see that the CSE set CSE_SR_IDB that indicated it has erased all keys, but after i reprogram the flash, it directly return a 0x13 error code, which confused me much.

   as you describe "Making these variables global fixed everything.", can you specify the local variables?

0 Kudos
231 Views
jeffcampbell
Contributor III

This is starting to get extremely confusing.  I've switched to a fresh MPC5777C and started over, but I'm completely failing to get results out of it.  I've listed the code I've tried below.  The CSE is displaying inconsistent behavior and most of the time ignoring commands and not throwing error codes about them.

ramkey and myMsg are 128-bit arrays initialized beforehand.

cipher and final are empty 128-bit arrays.

   /* Load RAM key */

    CSE.P1.R = (uint32_t)ramkey;

    CSE.CMD.R = 0x08u;

    waitCSE();

    /* Encrypt message */

    CSE.P1.R = 0xeu;

    CSE.P2.R = 1u;

    CSE.P3.R = (uint32_t)myMsg;

    CSE.P4.R = (uint32_t)cipher;

    CSE.CMD.R = 1u;

    waitCSE();

    /* Decrypt message */

    CSE.P1.R = 0xeu;

    CSE.P2.R = 1u;

    CSE.P3.R = (uint32_t)cipher;

    CSE.P4.R = (uint32_t)final;

    CSE.CMD.R = 3u;

    waitCSE();

waitCSE() is a stub function that just loops until the SR.BSY bit goes low.  Here's one sequence of events that demonstrates what I'm trying to get at.

  • I tried including the INIT command, but it gave an error code (0x2) for issuing an INIT after a secure boot or other initialization.  This makes sense because the device is configured to try a secure boot.  With this INIT command present, the encrypt and decrypt commands did not work.
  • I removed the INIT command.  The encrypt command failed, but the decrypt command executed and apparently "decrypted" the empty result from the encryption command.
  • I made various changes that had nothing to do with the CSE (e.g. I modified some DCF records for the secure boot but there was no net change in the configuration).  Now the encrypt command processes 64 bits of the message and the decrypt command does nothing.

I'm completely at a loss for what I'm missing; I'm doing nothing different from earlier successful experiments.  What could be causing this behavior?

0 Kudos