Showing results for 
Search instead for 
Did you mean: 

HAL_FLASHEx_Erase() fails sometime on STM32L4R9ZI

Associate II


I am using STM32L4R9ZI for my product and I am facing an issue in updating Flash. I am using flash_l4.c as provided by CubeIDE Project along with the STWIN Kit. I have attached the flash_l4.c for reference. I am using the FLASH_update() function to write data on Flash. Sometimes HAL_FLASHEx_Erase returns an error and the function bails out. Upon the second try the board gets stuck and watchdog happens. Upon the rest, when I try to read the content of Flash on that page it is all empty (i.e 0xFFFFFFFF) on that page.

  1. Can anyone clarify to me how the page got erased when HAL_FLASHEx_Erase() was unsuccessful?
  2. How I can resolve this issue in case of Failure as my second retry for FLASH_update() freezes the board? Most of the time I never face this issue.

Any help is appreciated.