[KEAZN64] Flash Protection Issue

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

[KEAZN64] Flash Protection Issue

1,503 Views
mohammedaboelna
Contributor III

Hello,

I am trying to protect lower region of the flash where I configured it to be for bootloader software.

As per datasheet, I have to set the configuration in register FPROT.

I succeeded to configure FPROT register to protect lower region till 8 KBs as when I tried to access the flash within the 8 KBs using flash commands, Flash driver has responded with error associated with flag "Region is protected".

So all of that till now is OK.

Now, I need to save this configuration in the flash so that I do not need to reconfigure FPROT register every time at startup.

When I searched for this topic, I've seen that the protection configuration can be programmed in address 0x40D so that just after reset, the needed configuration for the protection will be loaded in FPROT register automatically from address 0x40D.

MY ISSUE is here; I could not do the programming of this byte in the flash (I.e. address 0x40D).

When I write the configuration of FPROT register, data has not been transferred to address 0x40D which means it has not been programmed so I don't know how to program it in address 0x40D after writing this register (FPROT).

I also tried to use another mechanism which is trying to direct access the flash within sector that includes address 0x40D only (Erase this sector and re-write the sector but with changing byte in address 0x40D) which means hard code it by the needed configuration. This method totally ignored the FPROT register configuration.

Also this method unfortunately did not let me to connect to the controller using the debugger.

I believe that there is something fault happened !!.

Any help please to program the byte from register FPROT to address 0x40D safely.

Thank you in advance.

0 Kudos
Reply
5 Replies

1,174 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Mohammed Aboelnasr,

 - If you want to configure Flash Protection Register "FTMRH_FPROT", directly config address 0x40D ,

During the reset sequence, the FPROT register is loaded with the contents of the flash
protection byte in the flash configuration field at global address 0x40D located in flash
memory.

pastedImage_1.png

In KDS project, configure it in startup file :

pastedImage_2.png

- About "When I write the configuration of FPROT register, data has not been transferred to address 0x40D", there is no effect if we directly write FPROT register .

- From your description, I guess you want to change the protection region ? If yes, erase all the flash through debugger.

You can have a look at the application note  "Using the Kinetis Security and Flash Protection Features" AN4507   ->

3.3 Changing flash protection settings


Have a great day,
TIC

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

0 Kudos
Reply

1,174 Views
mohammedaboelna
Contributor III

Thank you for your prompt response.

The issue now that I have no access to the target using the debugger.

When I try to connect to the target using the debugger, I always receive this message
"Failed to initialize debug session".

I believe that protection should not prohibit connection using the debugger as this is protection not security,

So the behavior i obtained was really strange and I could not resolve it so far !!.

Do you have any proposals regarding this issue please ?

Also If I choose to flash the byte through the following sequence;

1- Take a copy for the data from address 0x0400 to address 0x0600 (512 bytes sector) in a temp array.

2- Modify in the temp array address 0x040D to the needed configuration.

2- Erase this sector only using command "Flash_EraseSector".

3- Program again the temp array including the updated byte of address 0x040D

Why is this sequence wrong ?

I believe it should work as well or at least do not cause this message "Failed to initialize debug session"

Would you have any ideas regarding the above steps and their effect please ?

Thank you in advance.

0 Kudos
Reply

1,174 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Mohammed Aboelnasr,

- Please check the data of your "needed configuration", maybe it secured by mistake.

-  The smallest size of protection is 2K in KEAZN64, not 512 bytes.

pastedImage_2.png

About how to config, please check the register of FTMRH_FPROT.

- About "Erase this sector only using command "Flash_EraseSector", do you meaning the Flash command?

after protected ,this do not work. You can use J-link command "Unlock kinetis"  to erase all flash.

-Which debugger do you used? If J-link, first use "Unlock kinetis" to have a try, there is a thread description it:

Unlocking and Erasing FLASH with Segger J-Link | MCU on Eclipse  


Have a great day,
TIC

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

0 Kudos
Reply

1,174 Views
mohammedaboelna
Contributor III

Hello,

I am using isystem debugger not Jlink.

0 Kudos
Reply

1,174 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi ,

I don''t know the isystem debugger well , you can check its user guide or their technical support iSYSTEM - iSYSTEM - Enabling Safer Embedded Systems  , to ask how to use it erasing .

BR

Alice

0 Kudos
Reply