Skip to main content
Rafael Bachmann
Associate II
March 17, 2020
Solved

How to erase pages on bank 2 on stm32g4?

  • March 17, 2020
  • 2 replies
  • 2707 views

I was trying to erase some flash pages on an stm32g474re nucleo (and on a custom board with the stm32g474veh3).

The flash pages are all on flash bank 2, because i read in the reference manual that flash bank 2 can be written while code is running from bank 1.

However, erasing pages in the second bank (by setting 'Banks' of the FLASH_EraseInitTypeDef to FLASH_BANK_2) has no effect.

In the example given in https://www.st.com/en/embedded-software/stm32cubeg4.html, (STM32Cube_FW_G4_V1.1.0/Projects/NUCLEO-G474RE/Examples/FLASH/FLASH_EraseProgram), there is a function defined called

uint32_t GetBank(uint32_t Addr)

which just returns FLASH_BANK_1.

This does not make sense to me, isn't flash bank 2 the one bank where erasing or writing makes sense?

Greetings,

Rafael

This topic has been closed for replies.
Best answer by TDK

The flash in the STM32G4 can be run in either single bank or dual bank mode. (Because why not make it as confusing as possible?)

Is your FLASH_OPTR_DBANK macro defined to enable dual bank mode?

The example you're pointing to runs in single bank mode, so all memory is bank 1.

2 replies

TDK
TDKBest answer
March 19, 2020

The flash in the STM32G4 can be run in either single bank or dual bank mode. (Because why not make it as confusing as possible?)

Is your FLASH_OPTR_DBANK macro defined to enable dual bank mode?

The example you're pointing to runs in single bank mode, so all memory is bank 1.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Rafael Bachmann
Associate II
March 19, 2020
Technical Moderator
April 1, 2020

Hello @Community member​ ,

You are right, the second bank in the STM32G4-Flash presentation is typo mistake.

In RM0440 is correct and it should be 0x0804 0000 - 0x0804 07FF.

I will raise this internally for correction.

Best Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
RBach.1
Associate
November 19, 2020