2020-03-17 10:08 AM
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
Solved! Go to Solution.
2020-03-18 06:23 PM
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.
2020-03-18 06:23 PM
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.
2020-03-19 07:04 AM
This is true, but my issue was different.
This app note has a typo:
It says that the second bank starts at 0x08004000 which is, well, ludicrous =)
2020-04-01 08:49 AM
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
2020-11-18 01:06 PM
Just noticed that you also got it wrong in the Youtube video of the presentation...
2020-11-18 01:38 PM
Hmm, are you sure that this example really uses single bank mode? Because dual bank is the default and the example also defines pages as 2 KB, not 4 KB as in single bank mode.
So did they maybe just implement the GetBank() incorrectly?
Best regards,
Anguel
2020-11-19 12:32 AM
For what its worth, see here: https://github.com/barafael/g4-dual-bank-example