2023-09-06 12:30 AM
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");
}
}
2023-09-06 12:44 AM
2023-09-06 01:31 AM
Thank you @Issamos, the code looks identical to my code. I Think I copied it from the same place.
Also setting the bit using the CubeProgrammer fails, so maybe I am missing some kind of precondition.
2023-09-06 05:02 AM
I have now tested with multiple boards. We have boards with different batches of the STM32H7 chip (same version but different production dates). Some chips report bootloader version 0x92 (see attached image), this are also the chips where setting the SECURITY bit fails.
All other boards that report bootloader version 0x91 work properly.