[CSE] What is RCHW and how to use valid RCHW during writing master key?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

[CSE] What is RCHW and how to use valid RCHW during writing master key?

3,712 次查看
jaejynshin
Contributor III

Hi experts

I got below error code in the CSE_ECR right after writing master key 

pastedImage_2.png

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.

pastedImage_3.png

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 ?

Thank you

Jaejyn

#CSE #ECR

10 回复数

2,510 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I would not focus on RCHW as it is correct.

pastedImage_1.png

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?

Peter

0 项奖励

2,510 次查看
jaejynshin
Contributor III

Thank you for your support

Privilege mode:

Supervisor mode

pastedImage_1.png

MMU for CSE

I didn't specify special MMU section for CSE area. The area is included in the last MMU section now

pastedImage_4.png

Code:

I used below simple codes

1) 

pastedImage_9.png

2)

pastedImage_6.png

3)

pastedImage_7.png

pastedImage_8.png

Currently, I am checking the LOCK1 status in C55FMC register 

[CSE] "system memory error" after writing master key 

But I can't change the value of the LOCK1 resister, so I am finding the reason.

0 项奖励

2,510 次查看
jaejynshin
Contributor III

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.

Thank you!

0 项奖励

2,510 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hi,

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.

Peter

2,510 次查看
jaejynshin
Contributor III

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 ?

Thank you

Jaejyn

0 项奖励

2,510 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hello,

First of all, there is already RM rev 8 available on NXP web.

Refer to chapter:

51.5.3 Reset Configuration Half Word (RCHW)

pastedImage_1.png

You have to write correct RCHW (for example 0x005A) to bootable location:

pastedImage_3.png

After you done writing to this lcoation the code will start on address which is on 0x4h offset from RCHW location.

See: 51.5.3.1 Application Start Address Register

pastedImage_4.png

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:

Example MPC5777C-PinToggleStationery GHS614 

And all other example we have created for MPC5777C

https://community.nxp.com/docs/DOC-329623 

Peter

2,510 次查看
jaejynshin
Contributor III

Oh.... I checked my device, but my device seems to have correct RCHW. (the boot sw of my device starts from 0x80_0000)

pastedImage_1.png

Is there any possibility that 0x015A is not valid for writing key into CSE ??

Thank you

Jaejyn

0 项奖励

2,510 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hello,

Your boot header is correct.

You have 0x015A ->  which mean boot with VLE active.

I see no issue here.

Peter

0 项奖励

2,510 次查看
jaejynshin
Contributor III

Thank you for your advice.

But the CSE Commad still fails

pastedImage_1.png

  • CMD 7: Load Key 
  • ECR 0x0C: System memory error

Is there any other case that Load Key fails with 0x0C error when RCHW is correct ?

Thank you

Jaejyn

0 项奖励

2,510 次查看
jaejynshin
Contributor III

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 ?

Thank you

Jaejyn

0 项奖励