2024-02-20 04:14 PM - edited 2024-02-21 04:31 PM
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();
2024-02-21 12:25 PM - edited 2024-02-22 10:26 AM
this never reads as set unless I set it, READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE);
I have created two programs that are identical other than the light they flash, the program residing in bank2 is never run, I have modified the stack pointer based on a previous workaround stated for a bootloader at D3 or less. I am at D5 when reading the address.
Do I need to set SYSCFG_MEMRMP_FB_MODE or is it set by the internal bootloader that if BF2B bit is set it will check for a valid program in bank2 and then run it.
The documentation is unclear, I have tried connecting with StmCubeProgrammer and flashed both binarys to 0x08000000 and 0x08040000 and toggled the BF2B bit but I have not been able to run from Bank2