viatorus wrote on Wednesday, April 17, 2019:
Hey everybody.
we are currently running many stability tests and found this issue:
The test below stops working after some seconds. Checking with the debugger, FreeRTOS does not schedule anymore and hangs inside the idle task. We are using an STM32F439xx with the CM3 port. GGC 7.2.
What the code does:
- Starts a
We are using an STM32F439xx with the CM3 port. GGC 7.2.
main task (prio 8). - Starts a watchdog task (prio 10) to provoke task switches.
- In an infinity loop: Start a test take (prio 8) and delete him.
What seems to happen before the crash (not 100% sure):
- The test task will be running (happens really rarly, see below).
- Calls Suspend.
- Main thread calls Suspend/Delete.
- Idle task runs for ever without context switches.
vTask1 is called if the counter is:
0x93, 0xAE and y.
y is variable but after y +0xE, the schedular hangs.
Our FreeRTOS config:
define configUSE_PREEMPTION 1
define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
define configUSE_IDLE_HOOK 0
define configUSE_TICK_HOOK 0
configUSE_TIME_SLICING 0
#define STACK_SIZE configMINIMAL_STACK_SIZE * 10
/* Structure that will hold the TCB of the task being created. */
StaticTask_t xTaskBufferMain;
StaticTask_t xTaskWD;
StaticTask_t xTaskBuffer1;
StackType_t xStackMain[ STACK_SIZE ];
StackType_t xStackWD[ STACK_SIZE ];
StackType_t xStack1[ STACK_SIZE ];
void vTask1(void *) {
vTaskSuspend(nullptr);
}
void vWD(void *) {
while (true) {
vTaskDelay(pdMS_TO_TICKS(1));
}
}
void vMain(void *) {
xTaskCreateStatic(vWD, "wd", STACK_SIZE, NULL, 10, xStackWD, &xTaskWD);
unsigned int i = 0;
while (true) {
TaskHandle_t handle1 = xTaskCreateStatic(vTask1, "task1", STACK_SIZE, NULL, 8, xStack1, &xTaskBuffer1);
vTaskSuspend(handle1);
vTaskDelete(handle1);
++i;
}
}
extern "C" int main(void) {
__enable_irq();
// 4 bits for pre-emption priority 0 bits for subpriority.
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
xTaskCreateStatic(vMain, "main", STACK_SIZE, NULL, 8, xStackMain,
&xTaskBufferMain);
vTaskStartScheduler();
return 0;
}
I tried to find the issue but I am out of ideas. Can someone please help?