Can't flash erase on "Single bank mode" (STM32G4)
Hi!
I have no problem with writing, reading, or erasing with dual mode, but erase stops working as soon as I change the DBANK option byte to "Single bank mode" (Uncheck it).
![]()
I assume there is something i need to change in the STM32G4XX files as well, because DBANK is always defiend:

I have tried to search on my own, but have not found any solution. Out of the 2 relevant hits I found online, one did not work and the other seems to be unverified and not easy to test
This is my code, which simply calls "stm32g4xx_hal_flash.c" and "stm32g4xx_hal_flash_ex.c" functions
if(HAL_FLASH_Unlock() == HAL_OK)
{
uint32_t PageError;
if(HAL_FLASHEx_Erase(&pEraseInit, &PageError) != HAL_OK)
{
HAL_FLASH_GetError();
}
while(HAL_FLASH_Lock() != HAL_OK);
}
Anyone have any suggestion?
Thank you in advance
