cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to Bank1 while running from Bank2 → Flash write fails

cuong
Associate II

Hi everyone,

I'm using STM32G474 with dual-bank Flash enabled (nDBANK = 0) and booting from Bank2 (BFB2 = 1). I'm implementing OTA firmware update by writing to the inactive bank while executing from the active one.

The update from Bank1 → Bank2 works fine.

But in the second update cycle, when running from Bank2 and trying to write to Bank1 (starting at address 0x08000000), HAL_FLASH_Program() always fails on the first double-word.

I have:

  • Verified that Write Protection is disabled (checked in STM32CubeProgrammer)

  • Unlocked Flash properly

  • Erased the target pages beforehand

  • No PCROP or secure area configured on Bank1

  • Flash error flag is HAL_FLASH_ERROR_WRITE_PROTECTION sometimes (even though WRP is not set)

I found some similar cases reported online (e.g. this one) where users mentioned that writing to Bank1 from Bank2 fails silently.

Is there an undocumented silicon limitation on STM32G4 when programming Bank1 from Bank2?

I would appreciate any official clarification or workaround from ST or others who solved this.

Thanks in advance!

11 REPLIES 11

Thank you @cuong

I work with a STM32L4A6, and the principle it is the same

I did a lot of test to find this.

I will check the application notes again , as I don't remember whether this information is mentioned there.

Pierre

cuong
Associate II

Thank you@PCu1 

I’ve already managed to solve it.
Thank you for reaching out!