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?
Solved! Go to Solution.
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.
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.
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?
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'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?