cancel
Showing results for 
Search instead for 
Did you mean: 

Getting FLASH_FLAG_PGSERR when calling FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE)

ZHaid.1
Associate II

I am trying to download Firmware into the Flash in the form of 4KB Chunks. However, on some pages, I am unable to update Flash because HAL_FLASHEx_Erase() returning an error as I am getting FLASH_FLAG_PGSERR for FLASH_WaitForLastOperation(). It is occurring randomly. Sometimes I am able to download the firmware completely on the flash and sometimes I run into this issue. 

I am calling FLASH_update() to copy the chunks into the flash. I have attached flash_l4.c for reference

Any help is appreciated 

2 REPLIES 2
TDK
Super User

> int FLASH_update(uint32_t dst_addr, const void *data, uint32_t size)

I'd recommend logging the parameters you pass to FLASH_update and noting which one fails. Looks like you already do some amount of logging, why not provide that information as well?

 

If you feel a post has answered your question, please click "Accept as Solution".
waclawek.jan
Super User

Are there interrupts enabled, or do you use RTOS?

One possible mechanism how PGSERR gets set is through inadvertent non-programming write to FLASH area by an errorneously written code, so what I'm  hinting at here is that maybe in some other concurrent process/interrupt this may be happening.

Try disabling/enabling interrupts around the programming functions.

JW