FreeRTOS application on RZ/A1H MPU hang-up issue

Hello,

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?

Thanks,
Veer

Hi @Veer
Welcome to the FreeRTOS Community Forums!
Some pointers you can check :

  • Do you have configASSERT() defined?
  • Do you have stack overflow checking set to 2?
  • What is the total stack size you are using for all the tasks?

Links can be found on this page: [Before the FAQ... - FreeRTOS™)

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.

Hi Rahul,

Thanks for your time in replying.

Yes, it is defined in Renesas API for RZ/A1H. Code snippet attached below.

	#define configASSERT( x ) if( (x) == 0 ) { R_OS_AssertCalled( __FILE__, __LINE__ ); }

Yes, configCHECK_FOR_STACK_OVERFLOW defined as 2.

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…

When I open the link which you attached the is not opening.
image

Apologies, the link has been updated.

Are you able to attach a debugger and see where the code is stuck , when you mention the application hangs up?

In addition what has already been suggested:

which isrs do you have in your system? Is your ISR stack large enough for all nested interrupts? Do your ISRs follow the ISR API requirements?

Do you have full source code for your 3rd party library?

Hi Rahul

Thanks, the site is opened.

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.
image

It hangs once in while.

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.

Hi RAc,

Thanks a lot for the suggestions!

  • I2C, UART, CAN, PWM, ADC, SPI, External interrupt(Keypad, Touchpad)
  • Please suggest me how to check it, I’m very much new to this platform. Currently I’m using e2studio IDE.
  • This software is supplied by Renesas Electronics Corporation with SDK.

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.