2022-11-23 03:23 AM
Hi,
In a matter of days, I'll have to port a user bootloader from STM32F303 to a STM32G473 mcu.
The question is about the Dual Bank feature of G473: since Dual Bank is active by default (DBANK=1), I'd prefer to NOT switch to Single Bank (as it is necessary to use specific Segger Flash Loaders).
So, keeping dual bank active, in my scenario:
I studied a bit the Flash_WriteProtection demo and the EraseInitStruct can be initialized to perform erase on bank1 or bank2.
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = FLASH_BANK_1; // or FLASH_BANK_2
EraseInitStruct.Page = StartPage;
EraseInitStruct.NbPages = EndPage - StartPage + 1;
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
The write API implementation seems to not care about which bank to write as it takes in only the destination address.
My doubt is about the execution: is it possible to execute code from bank2 or jump from bank1 to bank2 and back when BFB2 = 0?
Thanks for any help,
Regards
Solved! Go to Solution.
2022-11-23 09:50 AM
Hi @FPros.1,
yes, that's possible. Both banks are available simultaneously. The idea of having two banks is that code can run from one bank while programming the other. For example for EEPROM emulation. There is no known limitation yet, preventing the code to use both banks freely on the G4. We found problems doing the same with STM32G0, where the prefetch had to be disabled to prevent crashes while jumping from bank to bank. But no such problems on STM32G4.
BR,
J
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.
2022-11-23 08:38 AM
Hi @FPros.1,
yes, it's possible to jump from one bank to another. It's just a matter of correctly configuring the linker file to place the code on desired addresses.
BR,
J
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.
2022-11-23 08:45 AM
HI @JHOUD,
thanks for the prompt response.
So, if I understand you correctly, I can have a user application that spans across both banks so, i.e. the flow could go from bank1 to bank2 (and viceversa) in the same run.
Regards,
FP
2022-11-23 09:50 AM
Hi @FPros.1,
yes, that's possible. Both banks are available simultaneously. The idea of having two banks is that code can run from one bank while programming the other. For example for EEPROM emulation. There is no known limitation yet, preventing the code to use both banks freely on the G4. We found problems doing the same with STM32G0, where the prefetch had to be disabled to prevent crashes while jumping from bank to bank. But no such problems on STM32G4.
BR,
J
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.