cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX bug with STM32F407VG MCU and FreeRTOS

GShma
Associate

It was my hope that cubeMX bugs are constantly fixed with new releases. Unfortunately...

In the latest cubeMX generated code in FreeRTOSConfig.h file this is defined for os tick:

#define xPortSysTickHandler SysTick_Handler

which makes it jump into HardFault as there is nothing checks whether scheduler started or not.

WTF????

It was working correctly in previous release.

It was properly commented in FreeRTOSConfig.h:

/* IMPORTANT: This define MUST be commented when used with STM32Cube firmware, 
       to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
/* #define xPortSysTickHandler SysTick_Handler */

Then in stm32f4xx_it.c it was an ISR:

void SysTick_Handler(void)
{
 /* USER CODE BEGIN SysTick_IRQn 0 */
 /* USER CODE END SysTick_IRQn 0 */
 osSystickHandler();
 /* USER CODE BEGIN SysTick_IRQn 1 */
 /* USER CODE END SysTick_IRQn 1 */
}

And finally needed check:

void osSystickHandler(void)
{
#if (INCLUDE_xTaskGetSchedulerState == 1 )
 if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
 {
#endif /* INCLUDE_xTaskGetSchedulerState */  
  xPortSysTickHandler();
#if (INCLUDE_xTaskGetSchedulerState == 1 )
 }
#endif /* INCLUDE_xTaskGetSchedulerState */  
}

1 REPLY 1

@GShma​ - You may want to review this:

http://www.nadler.com/embedded/newlibAndFreeRTOS.html

Hope that helps,

Best Regards, Dave