STM32H7 option byte programming
Hi,
I'm trying to change the boot order of the STM32H745 to gate the M7 core and boot the M4 core.
This works fine in ST-Link utility ofcourse.
Now I'm trying this in code and this seems to not work.
I think the issue is with setting the bit from high to low.
FLASH_OBProgramInitTypeDef OBInit;
HAL_FLASHEx_OBGetConfig(&OBInit);
log_info("Usertype: %08x", OBInit.USERType);
if (OBInit.USERType & OB_USER_BCM7) {
log_info("Changing option bytes");
OBInit.USERType &= ~OB_USER_BCM7;
if (HAL_FLASH_OB_Unlock() == HAL_OK)
if (HAL_FLASH_Unlock() == HAL_OK)
if (HAL_FLASHEx_OBProgram(&OBInit) == HAL_OK)
if (HAL_FLASH_OB_Launch() == HAL_OK)
if (HAL_FLASH_OB_Lock() == HAL_OK)
if (HAL_FLASH_Lock() == HAL_OK)
{
log_info("Option bytes changed");
log_info("Requires rebooting");
//NVIC_SystemReset();
return;
}
log_info("Failed changing option bytes");All functions result in HAL_OK but the value doesn't change.
Am I missing something?
Melvin
