danielriegel wrote on Tuesday, March 19, 2019:
Hello,
I use freeRTOS v8.2.0 on a Cortex M4 (NXP LPC4078) and am getting a program crash in list.c, vListInsert() - function. It’s hanging in the for-loop where the 4 possibilities are described above. I’m searching for days in the freeRTOS forum, google, etc. but problem still exists and I didn’t get a solution yet.
In debugger it seems that it occurs on calling a xTaskNotifyWait() - command which calls in the middle taskEXIT_CRITICAL(); and taskENTER_CRITICAL(); where it doesn’t continue.
configASSERT() is defined and already helped me at some other problems.
What about the 4 possibilites?
1) Stack overflow -
see http://www.freertos.org/Stacks-and-stack-overflow-checking.html
I set #define configCHECK_FOR_STACK_OVERFLOW 1 and checked for vApplicationStackOverflowHook. It’s never called and never stays there in the endless loop.
In addition I checked the running tasks with its stack usage before calling xTaskNotifyWait():
File Transfer task R 2 268 19
AnyBus R 0 150 3
IDLE R 0 93 12
Tmr Svc B 3 186 13
NFC Tag B 0 262 6
console B 7 264 11
LED Control B 2 195 1
Event task B 2 178 15
ADC Control B 2 218 7
ext. ADC B 2 90 5
Eeprom Control B 2 207 8
abccCmdHandler B 4 583 10
LSB Driver S 0 175 2
“File Transfer task” is the running task, where vListInsert() - crash occurs.
2) Incorrect interrupt priority assignment, especially on Cortex-M
parts where numerically high priority values denote low actual
interrupt priorities, which can seem counter intuitive. See
http://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition
of configMAX_SYSCALL_INTERRUPT_PRIORITY on
http://www.freertos.org/a00110.html
I checked both websites, but unfortunately I do not completely understand Cortex M4 interrupt handling (it’s a bit complex:-)). In FreeRTOSConfig.h the following values are set:
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x3f
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#define configPRIO_BITS __NVIC_PRIO_BITS // which is 5
I already tried values 0-15 for configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY, that doesn’t change anything. But since it seems to crash in taskEXIT_CRITICAL() I would assume that it could occur in realtion to interrupt handling?
3) Calling an API function from within a critical section or when
the scheduler is suspended, or calling an API function that does
not end in "FromISR" from an interrupt.
As I wrote it seems to occur in xTaskNotifyWait() - command and there in the middle at taskEXIT_CRITICAL();. The function isn’t modified in any way.
4) Using a queue or semaphore before it has been initialised or
before the scheduler has been started (are interrupts firing
before vTaskStartScheduler() has been called?).
Since program is running fine before, all tasks are created, calling vTaskStartScheduler() is long in the past. The vListInsert() - crash doesn’t occur in initialization before scheduler started. It occurs on any actions when program run’s fine.
Do you need any additional information from me?
It would be really great if you have any hints what could cause the problem or which things I should check. Project is a bit in hurry and it’s annoying that I can’t continue its development due to this crash.
Thank you in advance!
Regards,
Daniel