Question
STM32H setting security bit fails
I am trying to set the SECURITY bit on a STM32H7B3ZITX using STM32CubeProgrammer (v2.10.0). But it fails, see attached screenshot.
I also tried setting the bit using the firmware. This does not produce any errors, but the bit is still not set. Following code is used for that:
FLASH_OBProgramInitTypeDef sFlashOptionBytes;
(void) HAL_FLASHEx_OBGetConfig(&sFlashOptionBytes);
/* Set the security bit if needed */
/* ------------------------------ */
if ((sFlashOptionBytes.USERConfig & FLASH_OPTSR_SECURITY) == RESET)
{
sFlashOptionBytes.Banks = FLASH_BANK_1;
sFlashOptionBytes.OptionType = OPTIONBYTE_USER;
sFlashOptionBytes.USERType = OB_USER_SECURITY;
sFlashOptionBytes.USERConfig = OB_SECURITY_ENABLE;
if (HAL_FLASHEx_OBProgram(&sFlashOptionBytes) == HAL_OK)
{
printf("Security bit set.\n");
HAL_FLASH_OB_Launch();
}
else
{
printf("Cannot set the security bit - ERROR\n");
}
}
I see the message "Security bit set.", but checking with STMCubeProgrammer shows the bit is not set.
Has anyone any ideas what can be wrong?
Has anyone any ideas what can be wrong?
