locking in MKV46F256VLL16

cancel
Showing results for 
Search instead for 
Did you mean: 

locking in MKV46F256VLL16

Jump to solution
453 Views
soaring_sun
Contributor III

Hi, I want the following to be done once I have flashed the program into the micro-controller. I am using TWR-KV46F150M evaluation board. These are the requirements that I am looking for when I say lock and unlock.

1. When the lock is enabled, the micro should not be able to erase the old code and flash new one when tried.

2. When lock is enabled, the micro doesn't let another person to read the information that is flashed before it was locked.

3. After the unlock is done, micro is as good as new and would allow the read/erase the previous flashed code.

do I have to change the clock settings for this? How will I be able to achieve it? Regards

Labels (1)
0 Kudos
1 Solution
390 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

Section 32.4.1 in reference manual has the detail.

jingpan_0-1616574081856.png

To unlock, Verify Backdoor Access Key command should be send. Section 32.5.10.10 has the detail. If the chip is locked, only firmware can do it.

 

Regards,

Jing

View solution in original post

8 Replies
439 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi soaring_sun,

About your requirement,

1. Yes, please use FRFA_FPROT register (Program Flash Protection Registers), the detail is in section 33.4.3.6 in RM.

2. If you mean you want to disable SWD/JTAG port, Please use FSEC[SEC] bits. During the reset sequence, the register is loaded with the contents of the flash security byte in the Flash Configuration Field(0x40C) located in program flash memory.

3. FSEC[KEYEN] controls backdoor. By input correct backdoor key, flash can be unlocked.

You needn't change clock settings for these functions.

Regards,

Jing

0 Kudos
435 Views
soaring_sun
Contributor III

Hi @jingpan 

1. I am referring to the following TRM and the section which you mentioned 33.4.3.6 doesn't exist in this. For this particular micro controller, how should I go on about the locking?

https://www.nxp.com/webapp/sps/download/preDownload.jsp?render=true 

2. When I disable the SWD/JTAG, how will I be able to unlock it once the locking process it complete? Since the SWD/JTAG is already disabled.

0 Kudos
425 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

1. Sorry my version is a bit old. please refer to 32.4.3.6.

jingpan_0-1616131873296.png

2. you can send a message to application, let application send Verify Backdoor access Key Command.

jingpan_1-1616132530756.png

 

Regards,

Jing

0 Kudos
422 Views
soaring_sun
Contributor III

Hi @jingpan 

I went through the documents and I have a fair idea of how it works. Do you have an example code for the same MKV46F256VLL16 board in which I will be able to lock and unlock effectively?

Regards

0 Kudos
414 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

It's very easy to lock and unlock. This control register's initial value is stored in flash address 0x400. When you want to change them, just modify the startup_kv46f16.s. It is at line 48

__attribute__ ((used,section(".FlashConfig"))) const struct {
unsigned int word1;
unsigned int word2;
unsigned int word3;
unsigned int word4;
} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE};

After you modify it, build the project and download, the setting will take effect immediately.

 

Regards,

Jing

0 Kudos
407 Views
soaring_sun
Contributor III

Hi @jingpan 

So, in the startup_kv46f16.s at line 48, 

0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE will be the password that corresponds to the four sections? So, when I have to lock them, I could change the above four to my password and lock them.

For unlocking, the same password should be written on the same four flash config and with programming that, it would unlock.

Is my understanding right?

Thanks and regards

0 Kudos
391 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

Section 32.4.1 in reference manual has the detail.

jingpan_0-1616574081856.png

To unlock, Verify Backdoor Access Key command should be send. Section 32.5.10.10 has the detail. If the chip is locked, only firmware can do it.

 

Regards,

Jing

View solution in original post

384 Views
soaring_sun
Contributor III

Thank you, @jingpan 

0 Kudos