cancel
Showing results for 
Search instead for 
Did you mean: 

CRP protection not working on STM32H563IIK6

gatadivijay
Associate II

I tried CRP protection for STM32H563IIK6.

 

But is it not working.

 

This is the code.

#define OB_RDP_LEVEL_0 ((uint8_t)0xAA)

#define OB_RDP_LEVEL_1 ((uint8_t)0x55)

#define OB_RDP_LEVEL_2 ((uint8_t)0xCC)

HAL_StatusTypeDef FLASH_If_WriteProtectionConfig(uint32_t modifier)

{

FLASH_OBProgramInitTypeDef OptionsBytesInit= {0};

u32 lu32_ReadValue =0;

 

if(modifier == OB_RDP_LEVEL_2 )

{

return 2;

}

 

HAL_FLASH_Unlock();

HAL_FLASH_OB_Unlock();

 

 

lu32_ReadValue = FLASH->OPTSR_PRG;

if(((lu32_ReadValue >>8) & 0xFF) == modifier )

{

return 1;

}

 

FLASH->OPTSR_PRG |= (modifier <<8);

 

//HAL_FLASHEx_OBProgram(&OptionsBytesInit);

/* Launch Option Bytes Loading */

HAL_FLASH_OB_Launch();

HAL_FLASH_OB_Lock();

HAL_FLASH_Lock();

return 0;

}

I'm calling this function with argument FLASH_If_WriteProtectionConfig(OB_RDP_LEVEL_1 )

1 REPLY 1
Jocelyn RICARD
ST Employee

Hello @gatadivijay,

STM32H5 introduced a new mechanism for flash protection.

RDP is replaced by PRODUCT STATE.

Please check documentation : reference manual, wiki. Also you should find videos about it. 

Best regards 

Jocelyn