TruePERSPECTIVES_logo.png

How to Debug FreeRTOS Projects on ARM Cortex-M Devices

Posted by Magnus Unemyr on Jan 18, 2017 10:00:00 AM

The embedded systems market in general is transforming quickly, and the RTOS market more specifically is no different. Not too many years ago, only forward-thinking development teams with a certain level of skills and budget used real-time operating systems in their designs. But in this day and time, using an RTOS is pretty much a requirement if you want to use middleware stacks (TCP/IP and USB comes to mind, for example).

At the same time, the traditional RTOS vendors are under strong pressure from free and open alternatives. On large high-end systems, EmbeddedLinux is almost the norm these days. Since EmbeddedLinux is too large to run on smaller embedded systems, other alternatives are a better fit for Cortex-M developers. FreeRTOS, developed by Richard Barry, is the shining star in this segment. FreeRTOS have a huge user base, as it is free, stable and easy to use. But with RTOS power comes debug problems. How do you debug a system based on FreeRTOS?

freertos_debugging.png

An RTOS adds certain objects to your design, for example tasks, semaphores, message queues, timers, etc. To understand the state of the system during a debug session, you need to look into these objects to understand what is going on. Without the capability to visualize the RTOS objects, you are pretty much debugging in the blind.

This is why professional developers need to have a C/C++ IDE that includes a debugger with RTOS kernel awareness features. In short, such a debugger can visualize the internal state of the RTOS as you stop on breakpoints and single-step the code. Atollic TrueSTUDIO is such an ARM Cortex-M IDE, with support for RTOS-aware debugging for many different real-time operating systems, including FreeRTOS, Segger embOS, Micrium uC/OS, ExpressLogic ThreadX, etc.

To aid developers, the FreeRTOS kernel awareness features in Atollic TrueSTUDIO provide the developer with a detailed insight into the internal data structures of the FreeRTOS kernel. During a debug session, the current state of the FreeRTOS kernel and the various FreeRTOS kernel objects such as tasks, mailboxes, semaphores and software timers, can be easily inspected in a set of dedicated views, in the Atollic TrueSTUDIO debug perspective.

Finding the FreeRTOS Views

A number of debugger views are available in the Atollic TrueSTUDIO debug perspective when debugging an application containing the FreeRTOS real-time operating.

 freertos_dbg1.png

These views are available from either the View top level menu or the Show View toolbar dropdown list button.

The FreeRTOS Tasks List

The FreeRTOS Task List view display detailed information regarding all available tasks in the target system. The task list is updated automatically each time the target execution is suspended.

There is one column for each type of task parameter, and one row for each task. If the value of any parameter for a particular task has changed since the last time the debugger was suspended, the corresponding row will be highlighted in yellow.

freertos_dbg2.png

Please note that due to performance reasons, stack analysis (the Min Free Stack column) is disabled by default. To enable stack analysis, use the Stack analysis toggle toolbar button in the View toolbar.

The FreeRTOS Queues List

The FreeRTOS Queues view display detailed information regarding all available queues in the target system. The queues view is updated automatically each time the target execution is suspended.

freertos_dbg3.png

There is one column for each type of queue parameter, and one row for each queue. If the value of any parameter for a particular queue has changed since the last time the debugger was suspended, the corresponding row will be highlighted in yellow.

The FreeRTOS Semaphores list

The FreeRTOS Semaphores view displays detailed information regarding all available synchronization objects in the target system, including:

  • Mutexes
  • Counting semaphores
  • Binary semaphores
  • Recursive semaphores

The view is updated automatically each time the target execution is suspended.

freertos_dbg4.png

There is one column for each type of semaphore parameter, and one row for each semaphore. If the value of any parameter for a particular semaphore has changed since the last time the debugger was suspended, the corresponding row will be highlighted in yellow.

The FreeRTOS Timers View

The FreeRTOS Timers view display detailed information regarding all available software timers in the target system. The timers view is updated automatically each time the target execution is suspended.

freertos_dbg5.png

There is one column for each type of timer parameter and one row for each timer. If the value of any parameter for a particular timer has changed since the last time the debugger was suspended, the corresponding row will be highlighted in yellow.

Summary

Using an RTOS in Cortex-M designs brings a lot of power and flexibility, and is now possible to add at low cost, using FreeRTOS or other real-time operating systems.

But debugging an RTOS-based application introduce new difficulties, and having a debugger that can visualize the internal RTOS state using kernel awareness features is a must. Atollic TrueSTUDIO is a great option here.

Read this whitepaper to learn more on professional Cortex-M development and debugging:

Read our ARM development  whitepaper!

 

Topics: RTOS, Atollic TrueSTUDIO