2023-05-05 03:47 AM - edited 2023-11-20 06:23 AM
Hi,
I am using MB1549C DK which has STM32U575ZIT6 MCU.
I have enabled trust zone as well as dual bank.
I have four hex file,
At bootup, I have read swapbank bit of OPTR reg.
uint8_t getActiveBank() {
volatile uint32_t remap = READ_BIT(FLASH_NS->OPTR, 0x1 << 20);
return remap == 0 ? 1 : 2;
}
I have used below reference function from standard example to modify swap bank bit.
NUCLEO-U575ZI-Q\Examples\FLASH\FLASH_SwapBanks
void toggleBankAndReset() {
/* Unlock the User Flash area */
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
/* Get the boot configuration status */
FLASH_OBProgramInitTypeDef OBInit;
HAL_FLASHEx_OBGetConfig(&OBInit);
/* Check Swap Flash banks status */
if ((OBInit.USERConfig & OB_SWAP_BANK_ENABLE) == OB_SWAP_BANK_DISABLE) {
/*Swap to bank2 */
/*Set OB SWAP_BANK_OPT to swap Bank2*/
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.USERType = OB_USER_SWAP_BANK;
OBInit.USERConfig = OB_SWAP_BANK_ENABLE;
HAL_FLASHEx_OBProgram(&OBInit);
/* Launch Option bytes loading */
HAL_FLASH_OB_Launch();
} else {
/* Swap to bank1 */
/*Set OB SWAP_BANK_OPT to swap Bank1*/
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.USERType = OB_USER_SWAP_BANK;
OBInit.USERConfig = OB_SWAP_BANK_DISABLE;
HAL_FLASHEx_OBProgram(&OBInit);
/* Launch Option bytes loading */
HAL_FLASH_OB_Launch();
}
}
I am able to update SWAPBANK bit and also able to read.
But when SWAPBANK is set to 1, at that time, firmware located at BANK2 doesn't run. It always run BANK1 firmware.
Here I have attached flash ld. file for all four hex file. and option byte configuration.
I want to switch between two firmware which are located in bank1 and bank2 in trust zone.
Can you please guide me, if anything I have missed ?
Does STM32U5 supports dual boot?
Thanks & Regards,
VIJAY
2023-05-23 10:06 AM
Hello @vijay_03,
Linker file should not get changed from Flash bank 1 to bank2.
An internal ticket (ID 152745) is submitted in order to update the example swap bank.
(PS: ID 152745 is an internal tracking number and is not accessible or usable by customers).
STM32U5 does not support dual boot.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.