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
解決済! 解決策の投稿を見る。
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
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
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?
Hope it can help you
BR
XiangJun Rong
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
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
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
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.
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
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
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