FreeRTOS with SystemView

From SEGGER Wiki
Revision as of 13:23, 28 April 2021 by Nino (talk | contribs)
Jump to: navigation, search

SystemView can be used to record applications which use FreeRTOS V8, V9 or V10. To properly display execution of the FreeRTOS scheduler, the FreeRTOS source needs to be slightly modified. Follow these instructions to configure your system for recording with SystemView.

Supported Software

SystemView has been tested with FreeRTOS V8.2.3, FreeRTOS V9.0.0, FreeRTOS V10.0.0 and V10.4.3. Newer versions should work accordingly.

Example Projects

These example packages include the modified FreeRTOS code as well as an example project, ready for use with SystemView. The example projects are created with Embedded Studio and can be used with almost any Cortex-M4 device. If you have trouble with your application and SystemView check for differences with the examples. If you need a starting point to create new applications, feel free to base them on the examples.

System Configuration

As reference the project from this article will be used. The configuration and patching process should work for all supported FreeRTOS versions similarly. Above you can find different example projects. The example project referenced below is the one for FreeRTOS V10.4.3.

  1. Get the patch file from the SystemView install folder for your corresponding FreeRTOS version and place it in the FreeRTOS/Source folder in your project.
  2. Apply the patch either with a patch tool or manually.
    1. On Linux there is a native patch tool: open terminal in the folder the patch is located at and call: patch -p1 -r . < FreeRTOS_10_4_3.patch
    2. On windows use one of the aviailable 3rd party patching tools e.g. git or do a manual patch.
  3. Create a new folder in your project and Embedded Studio project explorer where to place the SystemView sources at. For the referenced example /lib/SEGGER/SystemView is used.
  4. Add all SystemView Source files and folders to that folder according to the folder structure in SystemView source.
  5. Add the same files to the Embedded Studio in the project explorer accordingly.
  6. Add additional include paths for SystemView sources. You can add this in project options under Project->Options->Preprocessor->User Include Directories. This assumes that all FreeRTOS include paths are already set. If not, see the referenced Embedded Studio article for more details.
    1. (ProjectDir)/lib/SEGGER/SystemView/SEGGER
    2. $(ProjectDir)/lib/SEGGER/SystemView/Config
    3. $(ProjectDir)/lib/SEGGER/SystemView/Sample/FreeRTOS
  7. Add traceSTART(); to main

Troubleshooting

  • At the end of FreeRTOSConfig.h or before every FreeRTOS.h add #include "SEGGER_SYSVIEW_FreeRTOS.h"
  • Check if in FreeRTOSConfig.h define INCLUDE_xTaskGetIdleTaskHandle is 1.
  • Check if in FreeRTOSConfig.h define INCLUDE_pxTaskGetStackStart is 1.