cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32G473] Is it possible to keep dual bank active and executing the whole FLASH?

FPros.1
Associate II

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:

  1. the bootloader takes the first 16 kBytes of Bank1
  2. the user application takes the last 112 kBytes of Bank1 and the whole Bank2

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

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

3 REPLIES 3
Bubbles
ST Employee

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.

FPros.1
Associate II

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

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.