AnsweredAssumed Answered

STM32F0 read out protection problem

Question asked by Bartnik.Katarzyna on Mar 30, 2017
Latest reply on May 15, 2018 by Artur I

Hi,

 

I would like to use a software read protection on STM32F0. I've made such a function:

 

PROTECT_STATUS ReadProtectionConfig(uint8_t ProtectionLevel)
{
uint8_t status = OK;
FLASH_OBProgramInitTypeDef OB_Init;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
OB_Init.OptionType = OPTIONBYTE_RDP;
if (ProtectionLevel == 0) {
OB_Init.RDPLevel = OB_RDP_LEVEL_0;
} else if (ProtectionLevel == 1) {
OB_Init.RDPLevel = OB_RDP_LEVEL_1;
} else if (ProtectionLevel == 2) {
OB_Init.RDPLevel = OB_RDP_LEVEL_2;
} else {
status = RDPLevel_Error;
return status;
}

HAL_FLASHEx_OBProgram(&OB_Init);
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
return status;
}

 

but it don't work properly. I mean even if I choose OB_RDP_LEVEL_0 it blocks read out of flash memory. It is because the program can't perform the HAL_FLASH_OB_Launch(); function.

 

My problem is that I don't know why it happens and what should I do to make it better.

 

Could you help me?

 

Regards,

Kasia

Outcomes