Hi,
I have an aplication using K32L2B31VFM0A (256k FLASH). I want to secure and protect 64k of the flash by modifiying the file startup_k32l2b31a.c file.
Can you please confirm this is the correct configuration setup?
Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF3FFF};
How can I verify the protection was effective?
I read somewhere (I can't find where anymore) that ....., 0xFFFF3FFC}; would be more appropriate. Can you please confirm that?
I using MCUXpresso IDE v11.7.0 + SDK
Thank you very much! Andre
Solved! Go to Solution.
Hi @AndreVB
Yes, your sequence is correct, FPROT0 has the 8 more significant bits and FPROT3 the 8 least significant bits.
Also another observation, I have chapter 45.3.3.6 as Program Flash Protection Registers (FTFA_FPROTn) instead of 24.3.4.6. Please make sure you are using the correct reference manual for your K32L2B31VFM0A.
Best regards, Miguel.
Hi Miguel,
I already read both AN and I can't find the information I need there. Could you please be more specific? I have three questions:
1. {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFF00, 0xFFFF3FFF}; to secure and protect 64k. IS THAT CORRECT?
2. How can I verify the protection was effective?
3. Is , 0xFFFF3FFC the same as 0xFFFF3FFF ?
Thank you, Andre
Hi @AndreVB
The last 8 bits you are modifying affects the FTFA_FSEC register.
Please look into 2.1.1 FSEC register and field settings from AN4507 or 45.3.3.3 Flash Security Register (FTFA_FSEC) from your reference manual.
As the appnote and the manual says, this configure features such as:
Please check this chapters an read the register description.
Q1: Yes with the last one 0xFFFF3FFF you will secure the flash.
Q2: By changing the FTFA_FSEC register the flash will be secured, however, a method you can use to verify that the flash is secured by trying to initiate a debug session and it should return with an error.
Q3: According to the chapters I mentioned before, yes they are the same.
Please be carefull if you want to test this, I recommend you to keep the mass erase ENABLE, since combining security enable and mass erase DISABLE you will not be able to recover the board.
This method will secure all the flash, I will look for information to verify if it is possible to just secure a specified amount of bytes on the flash.
I hope this was a more informative for you.
Best Regards, Miguel.
Hi Miguel,
Thank you for the very detailed explanation. Agree, the Flash is SECURE now.
The remaining question is about the PROTECTION (FPROTn in blue).
According to the RM 24.3.4.6 each bit protects (Total Flash size/32) = 8k. So it seems I need to protect (clear) 8 bits of FPROT3 in order to protect 64k of 256k Flash. But I'm not so sure about the sequence of the field in blue. Can you please confirm that?
Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, FPROT0 FPROT1 FPROT2 FPROT3, 0xFFFF3FFF};
Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFF FF FF 00 , 0xFFFF3FFF};
Thank you,
Andre
Hi @AndreVB
Yes, your sequence is correct, FPROT0 has the 8 more significant bits and FPROT3 the 8 least significant bits.
Also another observation, I have chapter 45.3.3.6 as Program Flash Protection Registers (FTFA_FPROTn) instead of 24.3.4.6. Please make sure you are using the correct reference manual for your K32L2B31VFM0A.
Best regards, Miguel.
Hi @AndreVB
For more detailed information please read this application notes:
Before executing any flash security feature please make sure the state in which it will be configured, since this can secure completely your board and you will note be able to reprogramm it.
Best Regards, Miguel.