2020-07-24 12:46 PM
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
Solved! Go to Solution.
2020-07-24 01:10 PM
> OBInit.USERType &= ~OB_USER_BCM7;
I think you meant:
> OBInit.USERType = OB_USER_BCM7;
> OBInit.USERConfig = OB_BCM7_DISABLE;
What you posted makes no modification to BOOT_CM7.
Note that disabling the M7 core may make debugging harder, as it's the default access port for SWD.
edit: corrected a few typos
2020-07-24 01:10 PM
> OBInit.USERType &= ~OB_USER_BCM7;
I think you meant:
> OBInit.USERType = OB_USER_BCM7;
> OBInit.USERConfig = OB_BCM7_DISABLE;
What you posted makes no modification to BOOT_CM7.
Note that disabling the M7 core may make debugging harder, as it's the default access port for SWD.
edit: corrected a few typos
2020-07-24 01:58 PM
Ah yes that solved the issue.
Now I understand the UserType/UserConfig thing.
Yes it seems it makes debugging unusable. I changed the access port to "3 - Cortex-M4" but it still won't connect in STM32CubeIDE.
ST-Link will happily connect though on port 3.