Problem with programming flash with secure image

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with programming flash with secure image

Jump to solution
2,844 Views
v_snicarevs
Contributor III


Hi!

I have a custom board with MK22DX128VLK5.

Before I have enabled security bit in FlashConfig section it was all working fine.

The security is enabled as follows: Backdoor disabled, Mass erase enabled, Factory access granted, Sequrity enabled.

When I am trying to flash image using Flash from file in KDS 3.2.0 there are 2 possible scenarios:

Connection from "127.0.0.1" via 127.0.0.1

Copyright 2012 P&E Microcomputer Systems,Inc.

Command Line :C:\Freescale\KDS_v3\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_2.3.6.201602211227\win32\pegdbserver_console -device=NXP_K2x_K22DX128M5 -startserver -singlesession -serverport=7224 -interface=USBMULTILINK -speed=5000 -usejtag -port=USB1 -

CMD>RE

Initializing.

Target has been RESET and is active.

CMD>CM C:\Freescale\KDS_v3\eclipse\plugins\com.pemicro.debug.gdbjtag.pne_2.3.6.201602211227\win32\gdi\P&E\supportFiles_ARM\NXP\K2x\freescale_k22dx128m5_pflash_dflash_eeprom.arp

Initializing.

Initialized.

;version 1.05, 06/02/2014, Copyright 2014 P&E Microcomputer Systems, Inc. All rights reserved. www.pemicro.com [mk22_128k_x_pflash_dflash_eeprom_m5]

;device freescale, k22dx128m5, pflash_dflash_eeprom

;begin_cs device=$00000000, length=$14001000, ram=$20000000

Loading programming algorithm ...

Done.

CMD>EM

Erasing.

Module has been erased.

Reloading programming algorithm ...

done.

CMD>PM

Programming.

Processing Object File Data ...

.

Programmed.

CMD>VC

Verifying object file CRC-16 to device ranges ...

   block 00000000-00006173 ...

Ok.

   Checksum Verification Successful. (Cumulative CRC-16=$86C7)

CMD>RE

Initializing.

Device is Secure.

The flashing goes Ok until this moment. Than it asks me: Device is secure. Erase to unsecure? Yes or NO

So if I press Yes:

Device is secured. Erasing ...

Target has been RESET and is active.

WARNING - NO RESET SCRIPT FILE HAS BEEN CONFIGURED TO RUN!!!

TO MODIFY THE RESET SCRIPT SETTINGS, USE THE FOLLOWING MENU OPTION:

CONFIGURATION -> AUTOMATED SCRIPT OPTIONS

No breakpoints currently set.

Disconnected from "127.0.0.1" via 127.0.0.1

Target Disconnected.

Target Disconnected.

Which obviously leaves me with empty device.

If I press No:

Cannot enter background mode. Check connections. 

Device is secured. Erasing ...

WARNING - NO RESET SCRIPT FILE HAS BEEN CONFIGURED TO RUN!!!

TO MODIFY THE RESET SCRIPT SETTINGS, USE THE FOLLOWING MENU OPTION:

CONFIGURATION -> AUTOMATED SCRIPT OPTIONS

PE-ERROR: Error downloading to the device.

No breakpoints currently set.

Disconnected from "127.0.0.1" via 127.0.0.1

Target Disconnected.

Target Disconnected.

So it erases device anyway. The only way to program the device is disconnect debugger when the dialog appears.

In this case it works as expected.

Is there a reliable way to program a device with secure image?

(For small batch production)

I am using Kinedis Design Studio 3.2.0 on Win7, Multilink Universal debugger.

Thanks

Labels (1)
0 Kudos
Reply
1 Solution
1,902 Views
v_snicarevs
Contributor III

Well the difference was that I had Additional options: Mass erase on connect 'Ticked'

Unticking it indeed made it work as it should...

View solution in original post

0 Kudos
Reply
8 Replies
1,902 Views
Lorac
Contributor III

Hi,I live the same issue. I want to program my mcu(k22) with a code secured but the pegdbserver_console erases the part after the reset step. How can I solve it. I don't want to install KDS on pre-production bench to achieve it. 

Thanks for your help.

CD

0 Kudos
Reply
1,902 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Carol,

Please check this thread :

https://community.nxp.com/message/490815 

Hope it helps

Alice

0 Kudos
Reply
1,902 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Viktors,

When you enable the security bit , if you load project again, yes, you need erase all , or it can not load and debug.

Hope it helps

Alice

0 Kudos
Reply
1,902 Views
v_snicarevs
Contributor III

Hi Alice @Alice_Yang

That is not a problem.

The problem is that if I load a secure image, it erases it straight after loading, even if I choose not to. So I have no way of loading secure image and not have it removed after this dialog:

Screenshot 2016-05-16 10.41.15.png

So if chose 'NO' this happens:

Cannot enter background mode. Check connections.

Device is secured. Erasing ...

WARNING - NO RESET SCRIPT FILE HAS BEEN CONFIGURED TO RUN!!!

TO MODIFY THE RESET SCRIPT SETTINGS, USE THE FOLLOWING MENU OPTION:

CONFIGURATION -> AUTOMATED SCRIPT OPTIONS

PE-ERROR: Error downloading to the device.

No breakpoints currently set.

Disconnected from "127.0.0.1" via 127.0.0.1

Target Disconnected.

Target Disconnected.

So my question is: is it possible to configure flash loader so it would not erase device if I tell it not to?

Thanks,

Viktor

0 Kudos
Reply
1,902 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Vitors,

I have test on my side , yes , if you choose No, it will download the project success and not erase the flash.

You can test one simple LED project, after you download with "No", reset your board ,you can see the the LED

light , that is to say the project download to the chip.

After security , we can not debug it , so the debugger is disconnect .

Hope it hleps

Alice

0 Kudos
Reply
1,902 Views
v_snicarevs
Contributor III

Hi @Alice_Yang

I have tried other board I have - TWR-K21D50M using on-board usb debugger.

I have loaded hellow_world_twrk21d50m example and modified startup_MK21DA5.S flash configuration section to enable security bit:

/* Flash Configuration */

    .section .FlashConfig, "a"

    .long 0xFFFFFFFF

    .long 0xFFFFFFFF

    .long 0xFFFFFFFF

    .long 0xFFFFFFFF

So I am flashing an image:

Screenshot 2016-05-19 11.39.43.png

And receiving a dialog:

Screenshot 2016-05-19 11.41.20.png

After I chose 'NO'. this is the result:

Screenshot 2016-05-19 11.41.59.png

Obviously, device is erased and after resetting or power-cycling LED is not flashing.

Perhaps we are doing something differently...

0 Kudos
Reply
1,902 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Vktors,

1. After download , please re-insert your USB to the board again.

2.About the log of "erasing ...". this is meaning before download , erase the flash.

3. I test it on the board , i create one simple project on my side , it light the D9 led on board,

and i send it to you . On my side it can work well when i select "No" .


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,903 Views
v_snicarevs
Contributor III

Well the difference was that I had Additional options: Mass erase on connect 'Ticked'

Unticking it indeed made it work as it should...

0 Kudos
Reply