1932911_en-US

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

1932911_en-US

1932911_en-US

Code Readout protection on MKE04Z8

Dear all


I have an MKE04Z8 and use Keil to program it. The MKE04Z4_DFP Package have Version 14.0.0.

How can I turn on the code readout protection in the device?


Here is what I tried:

When I try to set the read out protection the MCU does not start anymore. I tried the following:

In "startup_MKE04K4.S" I altered the flash config from

/* Flash Configuration */
.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFEFFFF

.text
.thumb


to


/* Flash Configuration */
.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFDFFFF

.text
.thumb


Where's my mistake? 

Any help appreciated.

Kind regards

Christian


Re: Code Readout protection on MKE04Z8

Ok, I found it...

I download the code with KEIL. When I activate the Reaout Protection, Keil cannot start the debug session. It's very peculiar, but Keil then erases the code without special notice. Having done so, the CPU does not have any code to start.

Probably there's some higher sense behind that behaviour. Since I usually work with Crosswoks, I did not expect that at all.

Hope that helps 

Chris

Re: Code Readout protection on MKE04Z8

Hi,

Case 1:

After you download the SDK package, pls try to load/run the example code without any change, the chip is in unsecurity mode.

xiangjun_rong_0-1724394057724.png

then run a uart terminal, and check if the terminal can echo the input character.

Then you can power off and connect for example  J-Link device and tools, and check if you can read code or data with J-link via SWD port


case2:

You can change the security to

__attribute__ ((used,section(".FlashConfig"))) const struct {

unsigned int word1;

unsigned int word2;

unsigned int word3;

unsigned int word4;

} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFDFFFF};

 

then run a uart terminal, and check if the terminal can echo the input character.

Then you can power off and connect for example  J-Link device and tools, and check if you can read code or data with J-link via SWD port. In the case, because the SWD is blocked, the J-Link device can not be read.


Hope it can help you

BR

Xiangjun Rong

Re: Code Readout protection on MKE04Z8

Hi XiangJun Rong

I followed you advice, but I could not find an example using the Read-Out protection. Could you point me to the one you're talking about?

Kind regards

Chris

Re: Code Readout protection on MKE04Z8

Hi,

Pls download SDK from the website for FRDM-KE04 board, there is a lot of examples.

Hope it can help you

BR

XiangJun Rong


xiangjun_rong_0-1724292697467.png


Re: Code Readout protection on MKE04Z8

Hi XiangJun Rong

Thank you for your answer. When I do this, the code does not start anymore.

Do you have a smple project, where it works?

Kind regards

Chris

Re: Code Readout protection on MKE04Z8

Hi,

As you change the flash configure from .long 0xFFFEFFFF to .long 0xFFFDFFFF, it means that only the FTMRE_FSEC register has chnanged, especially, SEC bits change from 10 in binary(unsecure mode) to 01 in binary(secure mode). After reset, the chip is in secure mode, the SWD port is blocked, you can not read code/data from SWD port.

But the secure or unsecure mode does NOT take effect on the chip running.

As a test, after you restore to unsecure mode after mass erasing and redownloading, can the KE04 run fine again?


xiangjun_rong_0-1724233868901.png

Hope it can help you
BR

XiangJun Rong

Re: Code Readout protection on MKE04Z8

Dear XuZhang

Thank you for working on the question. 

As to my understanding, this is something every Product in the market needs to have. I tried different flags but I was not successful. Maybe you could ask the designer of the startup file.

Just to add.. It worked in previous versions of the library.

Kind regards

Chris

Re: Code Readout protection on MKE04Z8

hi,Chrigolat

Sorry for replying to your email so late. I have received your question and will deal with it as soon as possible.

BR

Xu Zhang

Tags (1)
No ratings
Version history
Last update:
‎11-21-2025 04:36 PM
Updated by: