Skip to main content
GShma
Visitor II
May 28, 2019
Question

STM32CubeMX bug with STM32F407VG MCU and FreeRTOS

  • May 28, 2019
  • 1 reply
  • 617 views

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 */ 
}

This topic has been closed for replies.

1 reply

Dave Nadler
Senior III
August 7, 2019

@GShma​ - You may want to review this:

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

Hope that helps,

Best Regards, Dave