cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in IRQ management during HAL Library initialization

Sebastien1
Associate II

STM32CubeMX version : 4.26.1

Chipset : STM32F207VCT

Hello,

In HAL code initialization, the code don't manage correctly the Interrupts initialization. I found this bug in UART part, TIM2 (use for FreeRtos) part and ETH part.

Every time the software launch, the code initialization enable the interrupt before the structure initialization which manage the interrupt !

So, if you place a breakpoint after a interrupt, and you click on reset software, the interrupt stay active and every time the software is launched, the software crashed (in HAL function) or stay stuck in interrupt.

For instance, currently, for TIM part :

  • Start of appplication.
  • In HAL_InitTick :
  /*Configure the TIM2 IRQ priority */
  HAL_NVIC_SetPriority(TIM2_IRQn, TickPriority ,0); 
  
  /* Enable the TIM2 global Interrupt */
  HAL_NVIC_EnableIRQ(TIM2_IRQn); 
  • 10 lines after :
  /* Initialize TIM2 */
  htim2.Instance = TIM2;

So, if the interrupt flag is at 1 at the beginning of the software, the interrupt fire at HAL_NVIC_EnableIRQ. As HTIM2 is not initialized, the instance variable is equal to NULL, and the interrupt never stop ...

In Ethernet initialization, it is the same manner, but the crash fired is in "ethernetif.c" file.

If a interrupt start just after the interrupt enable, the interrupt function call HAL_ETH_RxCpltCallback function, but the s_xSemaphore variable is not set. So the software crash.

Current version of HAL_ETH_RxCpltCallback :

/**
  * @brief  Ethernet Rx Transfer completed callback
  * @param  heth: ETH handle
  * @retval None
  */
void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
{
  osSemaphoreRelease(s_xSemaphore);
}

Corrected version :

/**
  * @brief  Ethernet Rx Transfer completed callback
  * @param  heth: ETH handle
  * @retval None
  */
void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
{
  if (s_xSemaphore == NULL) return;
 
  osSemaphoreRelease(s_xSemaphore);
}

Thanks in advance for the corrections.

Best regards.

0 REPLIES 0