2020-07-08 10:02 AM
Hi,
I'm trying to protect my code from being able to read by others.So I chose readout protection level-1,I could make it read protected and I'm not able disable it by using readout protection level-0,I have to disable it using ST link utility.But I want to disable readout protection using code itself.Please can someone correct me where I went wrong?
Thank you.
Enable readout protection level 1:
FLASH_Unlock() ;
if(!(FLASH_OB_GetRDP())
{
FLASH_OB_Unlock() ;
state = FLASH_OB_RDPConfig(OB_RDP_Level_1) ;
if(state == FLASH_COMPLETE)
FLASH_OB_Launch();
FLASH_OB_Lock() ;
}
FLASH_Lock() ;
Disable readout protection level 1:
FLASH_Unlock() ;
if((FLASH_OB_GetRDP())
{
FLASH_OB_Unlock() ;
state = FLASH_OB_RDPConfig(OB_RDP_Level_0) ;
if(state == FLASH_COMPLETE)
FLASH_OB_Launch();
FLASH_OB_Lock() ;
}
FLASH_Lock() ;
2020-07-08 10:39 AM
Erm, that's a rather strange idea ... Changing RDP to level 0 causes a mass erase of flash. Is that really your intention?
2020-07-08 11:34 AM
Level 1 protect flash against debug SWD interface , but you can upgrade or owerwrite flash with bootloader or other type code.
Switch back to level 0 equal erase flash, maybe can do with code run from ram .
2020-07-08 09:11 PM
Thanks for the quick reply.
My intention is to being able to enable and disable the readout protection level 1.Enabling part is working,but disabling part is not working(which is working through ST-Link Utility).After executing disabling logic also it says readout protection is still enabled.
Are disabling steps correct ?
Thank you.
2020-07-08 09:12 PM
Thanks for the quick reply.
My intention is to being able to enable and disable the readout protection level 1.Enabling part is working,but disabling part is not working(which is working through ST-Link Utility).After executing disabling logic also it says readout protection is still enabled.
Are disabling steps correct ?
Thank you.
2020-07-11 06:57 AM
It simply doesn't make any sense to disable the readout protection in your code.
Read the RM carefully regarding the implication of the various RDP levels.
2020-07-11 06:27 PM
Is the stlink doing a flash erase, switch level 0, rewrite flash? Then your sw won't have a backdoor.
2020-07-11 11:57 PM
I cant say your code is ok or not. But in fact when you build and run this code from flash then on moment execution instruction to change level to 0 MCU internaly erase full flash and next instructions in your code after this dont exist..
I write that maybe when you move this code to RAM and run here maybe work, but RDP is protection then i mean your idea is bad. I dont have more reply...