stm32f1xx_hal_driver icon indicating copy to clipboard operation
stm32f1xx_hal_driver copied to clipboard

Bug in HAL_FLASHEx_Erase_IT - if process already ongoing then pFlash remains locked

Open pi opened this issue 2 years ago • 4 comments

HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)
{
  HAL_StatusTypeDef status = HAL_OK;

  /* Process Locked */
  __HAL_LOCK(&pFlash);

  /* If procedure already ongoing, reject the next one */
  if (pFlash.ProcedureOnGoing != FLASH_PROC_NONE)
  {
>>> here must be  __HAL_UNLOCK(&pFlash); 

pi avatar Jul 24 '23 10:07 pi

Hello @pi,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards, Rania

RJMSTM avatar Jul 28 '23 12:07 RJMSTM

See also STM32CubeF4#88.

ALABSTM avatar Aug 11 '23 12:08 ALABSTM

Hi @pi,

Could you please give us more details on how you encountered this issue so that we can better analyze it?

With regards,

TOUNSTM avatar Aug 18 '23 11:08 TOUNSTM

Hi @TOUNSTM

I found this error while examining the function code. In fact, this error should never occur. Flash remains locked during any operations, so the condition (ProcedureOnGoing != FLASH_PROC_NONE) will never be satisfied. It's just that the eye caught on the potential for a deadlock to occur.

pi avatar Sep 01 '23 09:09 pi

Hello @pi,

Indeed, the LOCK/UNLOCK mechanism is set to be removed from the HAL_FLASHEx_Erase_IT() and HAL_FLASH_Program_IT() APIs. Consequently, your change request is no longer applicable. Please allow me to close the issue.

Thank you for your understanding, and we appreciate your report.

TOUNSTM avatar Jun 26 '24 10:06 TOUNSTM

ST Internal Reference: 185075

TOUNSTM avatar Jun 26 '24 10:06 TOUNSTM