cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429ZI Flash programming: Spurious PGPERR and PGSERR

SFahr
Associate III

I'm writing a firmware on a STM32F429ZI Discovery board. The firmware runs on Flash bank1 and erases/programs Flash bank2. When I try to erase or program bank2 the error flags PGPERR and/or PGSERR will be set without any plausible reason.

Example:

FLASH_EraseInitTypeDef EraseInit;
EraseInit.TypeErase   = FLASH_TYPEERASE_MASSERASE;
EraseInit.Banks   = FLASH_BANK_2;
EraseInit.Sector  = 0;
EraseInit.NbSectors  = 0;
EraseInit.VoltageRange   = FLASH_VOLTAGE_RANGE_3;
uint32_t SectorError = 0;
HAL_StatusTypeDef status0 = HAL_FLASH_Unlock();
uint32_t error0 = HAL_FLASH_GetError();
HAL_StatusTypeDef status1 = HAL_FLASHEx_Erase(&EraseInit, &SectorError);
uint32_t error1 = HAL_FLASH_GetError();
HAL_StatusTypeDef status2 = HAL_FLASH_Lock();
  1. HAL_FLASH_Unlock() returns HAL_OK, FlashError = 0
  2. HAL_FLASHEx_Erase() returns HAL_ERROR, FlashError = 2 (PGSERR)

Now I found out that if I just ignore and clear PGPERR and PGSERR in my firmware, everything works fine. I can erase and program the Flash bank2 and the the verification shows that everything is correct.

There is nothing stated in the Errata sheet or anywhere.

Could you please look into this issue?

1 REPLY 1
jwoerle
Associate III