mcuxpresso: how to set micro's flash security when Tee tool is not available?

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

mcuxpresso: how to set micro's flash security when Tee tool is not available?

Jump to solution
1,178 Views
Kratz
Contributor IV

How can the MKE02Z64's flash security be set when using the MCUXpresso IDE?  MCUXpresso says the Tee security tool is not available for the MKE02Z64 micro controller.  The programming language is C.

I have tried below which does not work. Which makes sense because the flash security is not part of the running program. 

FTMRH->FSEC = 0x01;

 

P&E generated code within Kinetis Design Studio made the below code:

/* Flash configuration field */
__attribute__ ((section (".cfmconfig"))) const uint8_t _cfm[0x10] = {
/* NV_BACKKEY0: KEY=0x13 */
0xD3U,
/* NV_BACKKEY1: KEY=0x86 */
0x2BU,
/* NV_BACKKEY2: KEY=0x77 */
0x49U,
/* NV_BACKKEY3: KEY=0x22 */
0xD5U,
/* NV_BACKKEY4: KEY=0x45 */
0xF4U,
/* NV_BACKKEY5: KEY=0xAC */
0xA2U,
/* NV_BACKKEY6: KEY=0x76 */
0x99U,
/* NV_BACKKEY7: KEY=0x67 */
0x50U,
0xFFU,
0xFFU,
0xFFU,
0xFFU,
/* NV_EEPROT: DPOPEN=1,??=0,??=0,??=0,??=0,DPS=7 */
0x87U,
/* NV_FPROT: FPOPEN=1,??=1,FPHDIS=1,FPHS=3,FPLDIS=0,FPLS=3 */
0xFBU,
/* NV_FSEC: KEYEN=0,??=1,??=1,??=1,??=1,SEC=1 */
0x3DU,
/* NV_FOPT: ??=1,??=1,??=1,??=1,??=1,??=1,??=1,??=1 */
0xFFU
};

0 Kudos
1 Solution
1,147 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Kevin,

In order to change FSEC bit in MCUXpresso please first install MCUXpresso SDK of your device. You can download in the link below, or you can directly import it by clicking the Install New Plugin SDKs button in the IDE.

Welcome | MCUXpresso SDK Builder

image.png

Then, create a new project using new SDK project wizard or import example from SDK.

If you see startup_mke02z4.c file in the project you will find the Flash config section. These 16-byte section is the flash configuration field and it is related to the following snippet from the RM.

image.png

This means that to enable flash security you will need to change the highlighted byte from FE to FD.

image.png

I hope this helps!

Have a great day,

Felipe

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored. Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

------------------------------------------------------------------------------ 

View solution in original post

3 Replies
1,148 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Kevin,

In order to change FSEC bit in MCUXpresso please first install MCUXpresso SDK of your device. You can download in the link below, or you can directly import it by clicking the Install New Plugin SDKs button in the IDE.

Welcome | MCUXpresso SDK Builder

image.png

Then, create a new project using new SDK project wizard or import example from SDK.

If you see startup_mke02z4.c file in the project you will find the Flash config section. These 16-byte section is the flash configuration field and it is related to the following snippet from the RM.

image.png

This means that to enable flash security you will need to change the highlighted byte from FE to FD.

image.png

I hope this helps!

Have a great day,

Felipe

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored. Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

------------------------------------------------------------------------------ 

1,137 Views
Kratz
Contributor IV

My board is a production PCB with a 32 pin chip instead of the being the demo board, so I don't think the SDK would work.  However, I did find the code you showed in the startup_mke02z4.c file.  I was able to change the hexadecimal "E" to a "D".  The Chip is now Secure.  Since there is no SDK, there should be no other way the security bytes in setup file could get overridden is there?

Thank you for your help!

0 Kudos
1,161 Views
Kratz
Contributor IV

It looks like setting up an attribute statement like this is needed.  I am not sure how to tell the compiler how to set location 0x400 as the place for this:

const uint8_t __attribute__((section("0x400"))) _cfm[0x10] = {

Also I read in the chip manual to add the array to the end of the vector table which I did on a bare metal project.  In MCUXpresso header file there was an incomplete vector table.  I have not figured out how to add the vector table this way either.

0 Kudos