I’m working on multitasking application with FreeRTOS on RZ/A1H MPU.
This application uses TES Guiliani graphics library for GUI. This application hangs up randomly after some time of execution. I have 3 tasks in the application. These tasks are GUI task, TASK2(UART, I2C, PWM, ADC, RTC, CAN), and one task for SPI channels.
Initially there were more tasks, when I comment out few tasks and added in TASK2, hang-up issues minimizes but still occurs!
Can anyone guide me how to debug which task/s are causing this issue?
Then, are you sure your stack is large enough for all the tasks? Since, you mention the hang issue minimizes when some tasks are deleted, do you mean the time it takes to hang starting from execution is increased?
You can try increasing the total stack size and see the results.
Task1 - 4KB, Task2 - 2KB, Task3 - 1KB.
Total - 7KB.
By using UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; I assume there is enough stack is available, attached image for your reference. Please correct me, if I’m in wrong way…
It won’t support attaching to a running application.
Previously when it hangs while debugging, we paused the task it stops in prefetch_handler or abort_handler line.
In addition to what @RAc suggested, I would likely see the value of various fault status registers like DFSR, IFSR, and Fault address registers, to get an idea on which line might be causing the prefetch abort or data abort.
You can put some known pattern at the end of the ISR stack and when the application hangs, you can examine that memory in the debugger and see if it is changed. If it is changed, it likely indicates that the ISR stack has overflowed. We use the same technique to check for task stack overflow in the kernel -
FreeRTOS APIs that end in “FromISR” can be called from ISRs which run at a priority less than or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY. This depends on the port if the port and hardware supports selective masking of interrupts - you can check with Renesas about this as you got the FreeRTOS port from them.
One other thing you can try is to comment out tasks and ISRs to narrow down the problematic part.