STM32G473QET6 Dual Bank/Boot Mode Question
I am having some issues implementing dual bank/boot.
I have set up a dummy project starting at base address 0x08000000 for 256k bytes that will turn on a red LED
I have another dummy project starting at base address 0x08040000 for 256k bytes that will turn on a green LED
Based on the example from 474 Dual Boot Mode, it seems you set the system in DBANK mode by setting the bit in FLASH_OPTR as well as setting the BF2B bit.
Now I am confused if the BF2B forces booting from bank 2 or it just means it is allowed, cause I also see the function
FLASH_OBProgramInitTypeDef OBInit;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&OBInit);
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.USERType = OB_USER_BFB2;
if (((OBInit.USERConfig) & (OB_BFB2_ENABLE)) == OB_BFB2_ENABLE) {
OBInit.USERConfig = OB_BFB2_DISABLE;
} else {
OBInit.USERConfig = OB_BFB2_ENABLE;
}
if (HAL_FLASHEx_OBProgram(&OBInit) != HAL_OK) {
// uint32_t errorCode = HAL_FLASH_GetError();
while (1) {
HAL_Delay(1000);
//HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
}
}
if (HAL_FLASH_OB_Launch() != HAL_OK) {
//uint32_t errorCode = HAL_FLASH_GetError();
while (1) {
HAL_Delay(100);
//HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
}
}
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
