cancel
Showing results for 
Search instead for 
Did you mean: 

Infinite loop when a first FreeRTOS thread generated from STM32CubeIDE is removed manually

newbie_stm32
Associate III

Hi Community,

I encountered an interesting issue: I first generated multiple FreeRTOS threads (in which the first thread is the dummy thread) using STM32CubeIDE (CMSIS V1) and then copied them to a CMake project. It worked well I have added a few implementations and all were good until the time came to remove the dummy thread. When it is being removed, it goes to execute the first thread but then moves into an infinite loop (this is verified by debugging and single stepping), and because of the watchdog configured for 5 seconds, it resets. And it repeats.

Has anyone encountered this issue?

2 REPLIES 2
nouirakh
ST Employee

Hello @newbie_stm32 

The issue you're encountering when removing the dummy thread in a FreeRTOS project could be due to a variety of reasons.Could you ensure that the stack sizes for the remaining tasks are adequate. A stack that is too small can lead to a stack overflow, which might cause the behavior you're observing. Also, Check if the dummy thread was interacting with ISRs or handling any signals or events that are no longer being managed.
Since you mentioned a watchdog timer, it's possible that the system is not kicking the watchdog within the required interval due to the removed thread. Ensure that the remaining threads or the idle task are clearing the watchdog timer as needed.

Hi @nouirakh, thanks for your reply.

I am elaborating on some points here

  1. A stack size of 128 words was used for the dummy task and was a low-priority thread (osPriorityLow). It blinks an LED to ensure the system is up and running. No watchdog refresh or interaction with ISR is done in this thread. 
  2. Removing this thread should not affect the stack management of other threads. And before removing the dummy thread the system was stable. All other tasks ran effectively without any issues.
  3. The watchdog timer is being hit as it is handled in one of the threads (other than the dummy thread) and since the threads are not in an execution stage due to an infinite loop, the watchdog was not refreshing.

What else can cause the issue?