This is fun. So far I have bricked two processors and it feels like trying to find your keys, in the dark, in a cattle pasture. You blindly keep trying things, but the stuff in your hand isn't quite a set of keys.
Anyway, between the MPC5644 censorship project, and AN3787, I've come up with a project where if I boot my TRK-MPC5634M board with SW2 depressed, it goes into the unlock code. If the switch isn't pressed, I check to see if *0xFFFDD8 == the top half of my key. If the processor seems to be locked, I start a blinky. If the processor isn't locked, I lock the processor.
It appears that if I lock the processor, the processor then resets. An odd result. But it also leaves me with a processor that is censored and doesn't have the default, or my chosen key. Is the reset an expected action?
If I press the button, it goes into the unlock code, then resets, and goes into the unlock code...
If the button isn't pressed, it goes into the lock code, resets, goes into the lock code...
Yes, I'm sure that the button works, but it does appear that I can't successfully query the key to see if it has been set.
So I seem to have to arrange for the debugger to jump in after the erase, in that infinitesimally short period when the processor is in a good state, which seems to be never.
Are there any best practices to see if the processor is censored when first firing up? Something that I can check, then bypass censoring for the rest of the life of the code?
I've plopped the whole project down in the doobly-doo. It's set up for S32DS 1.X and running on an MPC5634M on a TRK-MPC5634M.