Flash Erase on STM32G4 doesn't work as intended
I'm running a STM32G473CB with 128kb flash, and I'm getting some issues erasing pages in bank2 of the flash. Using HAL_FLASHEx_Erase the way it's meant to be used, like in the following code that's supposed to erase pages 30 and 31 of bank2, I don't get any result. No errors arise, yet the pages remain unerased.
HAL_FLASH_Unlock();
FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t PageError = 0;
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = FLASH_BANK_2;
EraseInitStruct.Page = 30;
EraseInitStruct.NbPages = 2;
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
{
...
}
HAL_FLASH_Lock();Whereas if I do the following (an erase through the bank boundary from bank1) the correct flash pages are erased and no errors are thrown.
HAL_FLASH_Unlock();
FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t PageError = 0;
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = FLASH_BANK_1;
EraseInitStruct.Page = 62;
EraseInitStruct.NbPages = 2;
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
{
...
}
HAL_FLASH_Lock();I have made sure that the flash is configured with dual bank mode on, and that no write protection areas are active.
I would appreciate if someone with a 128kb g4 device on hand could test the bank2 page erase to see if the problem is universal.
Thanks
