2023-09-21 07:40 PM
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
2023-09-21 08:19 PM
> 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?
2023-09-22 12:28 AM
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