I got below error code in the CSE_ECR right after writing master key
I found the reason of the error in the "AN4234_Using the Cryptographic Service Engine(CSE)MPC564XBC.pdf" document, but I still didn't understant the real reason.
I could find that RCHW is "Reset Configuration Harf Word" but I don't know what it is..
Could you any one tell me what is RCHW and how to use valid RCHW to write key correctly ?
I would not focus on RCHW as it is correct.
What comes to my mind is the user/supervisor mode. Are you in supervisor mode? (MSR.PR =1)
Do you have MMU for CSE configured?
Could you share a code where you are updating the key just before the failure?
Thank you for your support
MMU for CSE
I didn't specify special MMU section for CSE area. The area is included in the last MMU section now
I used below simple codes
Currently, I am checking the LOCK1 status in C55FMC register
But I can't change the value of the LOCK1 resister, so I am finding the reason.
Finally, I found the reason why "system memory error" occurred in my system.
The M1~M5 was assigned from local variable address, and the stack is used in the cache.
That is, stack is locked in the cache.
Because I assigned local variable addresses to the M1~M5 address, the CSE could not read the addresses.
After I gave the addresses of global variables to the M1~M5, this problem was solved.
As you did not specify which micro are you using, I will try to explain it in general.
RCHW is used when device is intended to boot from internal Flash.
Each boot sector in flash memory contains the Reset Configuration Half-Word (RCHW) at offset 00h. If the RCHW field BOOT_ID holds the value 5Ah then the sector is considered bootable.
SSCM module use the valid RCHW followed by application start address and starts executing application from this address.
So If you mess up RCHW you device won't detect any valid bootable address and device will start in a serial boot mode.
Additionally if you are not prepared to boot in serial mode the device will end in BAF/BAM code.
In reference manual you can find RCHW usually in reset and boot chapters.
Thank you for your fast answer
I am using mpc5777c.
I am usually refer "MPC5777CRM_rev6.pdf" and "e200z759CoreReferenceManual.pdf" to study my MPC
Could you let me know how to set the valid RCHW ?
First of all, there is already RM rev 8 available on NXP web.
Refer to chapter:
51.5.3 Reset Configuration Half Word (RCHW)
You have to write correct RCHW (for example 0x005A) to bootable location:
After you done writing to this lcoation the code will start on address which is on 0x4h offset from RCHW location.
See: 220.127.116.11 Application Start Address Register
Have in mind the offset from RCHW is 0x4h. The code will start on Address which is written on 0x4h offset. Not on 0x4h offset! (just in case you will misunderstood it)
You can also have a look on a reference example:
And all other example we have created for MPC5777C
Oh.... I checked my device, but my device seems to have correct RCHW. (the boot sw of my device starts from 0x80_0000)
Is there any possibility that 0x015A is not valid for writing key into CSE ??
Thank you for your advice.
But the CSE Commad still fails
Is there any other case that Load Key fails with 0x0C error when RCHW is correct ?
Then, maybe my device doesn't have valid RCHW and the boot mode is "Serial boot" now.
If I don't write the RCHW correctly, I can't write the key into the CSE, right ?