Nucleo-L4r5zi - Flash Erase and Write - Dual Bank
I had no issue writing to and erasing the banks on my nucleo a couple times but all of a sudden it started failing. I unlock the flash successfully clear flash error flags and try do a bank erase:
FLASH_EraseInitTypeDef erase;
erase.TypeErase = FLASH_TYPEERASE_MASSERASE;
erase.Banks = bank_to_erase;
if(HAL_FLASHEx_Erase(&erase, &err) != HAL_OK) {
uint32_t retcode = HAL_FLASH_GetError();
}retcode gets set to 0x20000 which corresponds to PEMPTY flag. However the area (bank 2) which I try to erase is not empty when i look at it with StmCubeProgrammer. Furthermore, although I see HAL_FLASH_GetError() return 0x20000 looking at SFR for Flash in the debugger does not show PEMPTY set:
I'm not sure if OB are important here but these are my current settings:
Any pointers or ideas appreciated. Thank you.