Skip to main content
Visitor II
June 1, 2021
Solved

Flash erase function HAL_FLASHEx_Erase issues with STM32L072cz

  • June 1, 2021
  • 2 replies
  • 958 views

Hi ,

I am using the STM32L072Cz LoRa discovery Board and I am doing the flash erase by using the HAL function "HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError)"

I given the Start address 0x08000000 and No of pages to be erased to be 400 .

then only page one has got erased and other pages didn't erased !!!

for testing i have given random page address and No of pages to be 1,then this function has erased.

please suggest me here why this function is not able to erase the more pages ???

    This topic has been closed for replies.
    Best answer by TDK

    Typically your code is at 0x08000000. Erasing FLASH currently in use by your code will lead to undefined or at least unsupported behavior.

    2 replies

    Graduate II
    June 1, 2021

    All the source is provided, you could inspect / analyze

    If passing a local variable/array ensure it is fully initialized.

    Check for error/status returned.

    Are you erasing code that's executing, or contains the active vector table?

    TDKAnswer
    Super User
    June 1, 2021

    Typically your code is at 0x08000000. Erasing FLASH currently in use by your code will lead to undefined or at least unsupported behavior.