Difference between revisions of "FreeRTOS with SystemView"

From SEGGER Wiki
Jump to: navigation, search
(Troubleshooting)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
SystemView can be used to record applications which use FreeRTOS V8, V9 or V10.
+
SystemView can be used to record applications which use FreeRTOS V8, V9, V10 or V11.
To properly display execution of the FreeRTOS scheduler, the FreeRTOS source needs to be slightly modified.
+
Up until V10, the FreeRTOS source needs to be slightly modified to properly display the execution of the FreeRTOS scheduler.
  +
Starting with V11 no changes to the kernel are required.
  +
  +
Independent of the used version, some additional source files need to be added to the project so the application may be recorded by SystemView.
  +
 
Follow these instructions to configure your system for recording with SystemView.
 
Follow these instructions to configure your system for recording with SystemView.
   
 
== Supported Software ==
 
== Supported Software ==
   
SystemView has been tested with FreeRTOS V8.2.3, FreeRTOS V9.0.0, FreeRTOS V10.0.0 and V10.4.3.
+
SystemView has been tested with FreeRTOS V8.2.3, V9.0.0, V10.0.0, V10.4.3 and V11.0.1.
 
Newer versions should work accordingly.
 
Newer versions should work accordingly.
   
 
== Example Projects ==
 
== Example Projects ==
   
These example packages include the modified FreeRTOS code as well as an example project, ready for use with SystemView.
+
These example packages include the instrumented FreeRTOS code as well as an example project, ready for use with SystemView.
The V8 and V9 example projects are created with Embedded Studio and can be used with almost any Cortex-M4 device. The example for V10.4.3. is created specifically for the [https://www.segger.com/products/debug-probes/j-trace/accessories/trace-reference-boards/overview/#cortex-m-trace-reference-board SEGGER Cortex-M Trace Reference Board]. So if you want to use that project on another hardware make sure to port the project accordingly.
+
The V8 and V9 example projects are created with Embedded Studio and can be used with almost any Cortex-M4 device. The example for V10.4.3 and V11.0.1 are created specifically for the [https://www.segger.com/products/debug-probes/j-trace/accessories/trace-reference-boards/overview/#cortex-m-trace-reference-board SEGGER Cortex-M Trace Reference Board]. So if you want to use these projects on another hardware make sure to port the project accordingly.
 
If you have trouble with your application and SystemView check for differences with the examples.
 
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.
 
If you need a starting point to create new applications, feel free to base them on the examples.
   
  +
* FreeRTOS V11.0.1:
  +
**[[Media:ES_V810b_FreeRTOS_V11_0_1_STM32F407_TRB_SystemView.zip|Example Project]]
 
* FreeRTOS V10.4.3:
 
* FreeRTOS V10.4.3:
 
**[[Media:ES_V542a_FreeRTOS_V10_4_3_STM32F407_TRB_SystemView.zip|Example Project]]
 
**[[Media:ES_V542a_FreeRTOS_V10_4_3_STM32F407_TRB_SystemView.zip|Example Project]]
Line 24: Line 30:
 
== System Configuration ==
 
== System Configuration ==
 
As reference the project from [https://wiki.segger.com/How_to_create_a_simple_FreeRTOS_project_with_Embedded_Studio#Setup this] article will be used.
 
As reference the project from [https://wiki.segger.com/How_to_create_a_simple_FreeRTOS_project_with_Embedded_Studio#Setup 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.
+
The configuration process works similarly for all supported FreeRTOS versions.
  +
  +
'''Note: Up until V10 the kernel needs to be patched, while starting with V11 the instrumentation was added natively. So if you are using FreeRTOS V11 and later you can skipt the section "Patching". Above you can find different example projects.'''
  +
  +
=== Patching ===
  +
  +
# Get the patch file from the SystemView install directory (in the subdirectory "Src/Sample/*") for your corresponding FreeRTOS version
  +
#* The patch for V10.4 may also be downloaded [[Media:FreeRTOSV10.4.zip|here]]
  +
# Place it in the FreeRTOS/Source folder in your project
  +
#* For Windows: You may use one of the available 3rd party patching tools, e.g. git or simply a manual patch
  +
#* For Linux: Open the terminal at the location of the patch and call "patch -p1 -r . < FreeRTOS_10_4_3.patch"
   
  +
=== Project configuration ===
The patch files and SystemView source for FreeRTOS V10.4 or later can be found here:
 
[[Media:FreeRTOSV10.4.zip|FreeRTOSV10.4.zip]]
 
   
  +
# Get the required SystemView and RTT source files either
# Get the patch file from the SystemView install folder (or the link above) for your corresponding FreeRTOS version and place it in the FreeRTOS/Source folder in your project.
 
  +
#* ...from the [https://www.segger.com/downloads/systemview/ download section on our website] or directly [https://www.segger.com/downloads/systemview/systemview_target_src here]
# Apply the patch either with a patch tool or manually.
 
  +
#* ...from the SystemView installation directory
## 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
 
  +
#* ...from our [https://github.com/SEGGERMicro/SystemView GitHub repository]
## On windows use one of the available 3rd party patching tools e.g. git or do a manual patch.
 
# 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.
+
# Create a new folder in your project and Embedded Studio project explorer where to place the SystemView sources
  +
#* For the reference example "/lib/SEGGER/SystemView" is used
# Add all SystemView Source files and folders to that folder according to the folder structure in SystemView source.
 
# Add the same files to the Embedded Studio in the project explorer accordingly.
+
# Add all SystemView Source files and folders to that folder according to the folder structure in SystemView source
  +
# Add the same files to the Embedded Studio in the project explorer accordingly
# At the end of FreeRTOSConfig.h or before every FreeRTOS.h add <code>#include "SEGGER_SYSVIEW_FreeRTOS.h"</code>
 
  +
# At the end of FreeRTOSConfig.h or before every "FreeRTOS.h" add <code>#include "SEGGER_SYSVIEW_FreeRTOS.h"</code>
# 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.
 
## (ProjectDir)/lib/SEGGER/SystemView/SEGGER
+
# Add the include paths for the SystemView sources
  +
#* They may be added using the 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.
## $(ProjectDir)/lib/SEGGER/SystemView/Config
 
## $(ProjectDir)/lib/SEGGER/SystemView/Sample/FreeRTOS
+
#* "(ProjectDir)/lib/SEGGER/SystemView/SEGGER"
  +
#* "$(ProjectDir)/lib/SEGGER/SystemView/Config"
# Add traceSTART(); to main
 
  +
#* "$(ProjectDir)/lib/SEGGER/SystemView/Sample/FreeRTOS"
  +
# In case of using FreeRTOS V10 or older: Add the define "USE_LEGACY_TRACE_API=1"
  +
# Add "traceSTART();" to main
   
===Troubleshooting===
+
=== Troubleshooting ===
 
* At the end of FreeRTOSConfig.h or before every FreeRTOS.h add <code>#include "SEGGER_SYSVIEW_FreeRTOS.h"</code>
 
* At the end of FreeRTOSConfig.h or before every FreeRTOS.h add <code>#include "SEGGER_SYSVIEW_FreeRTOS.h"</code>
 
* Check if in FreeRTOSConfig.h define <code>INCLUDE_xTaskGetIdleTaskHandle</code> is 1.
 
* Check if in FreeRTOSConfig.h define <code>INCLUDE_xTaskGetIdleTaskHandle</code> is 1.
 
* Check if in FreeRTOSConfig.h define <code>INCLUDE_pxTaskGetStackStart</code> is 1.
 
* Check if in FreeRTOSConfig.h define <code>INCLUDE_pxTaskGetStackStart</code> is 1.
 
* Unknown task names shown? Simply need to increase the value of <code>SYSVIEW_FREERTOS_MAX_NOF_TASKS</code> until all task names can be resolved. Keep in mind that FreeRTOS creates some tasks on its own so the number will be higher than the number of tasks that you created.
 
* Unknown task names shown? Simply need to increase the value of <code>SYSVIEW_FREERTOS_MAX_NOF_TASKS</code> until all task names can be resolved. Keep in mind that FreeRTOS creates some tasks on its own so the number will be higher than the number of tasks that you created.
  +
* Task names truncated? You can set the maximum task name length with config define configMAX_TASK_NAME_LEN.
   
 
[[Category:SystemView]]
 
[[Category:SystemView]]

Latest revision as of 12:13, 1 March 2024

SystemView can be used to record applications which use FreeRTOS V8, V9, V10 or V11. Up until V10, the FreeRTOS source needs to be slightly modified to properly display the execution of the FreeRTOS scheduler. Starting with V11 no changes to the kernel are required.

Independent of the used version, some additional source files need to be added to the project so the application may be recorded by SystemView.

Follow these instructions to configure your system for recording with SystemView.

Supported Software

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

Example Projects

These example packages include the instrumented FreeRTOS code as well as an example project, ready for use with SystemView. The V8 and V9 example projects are created with Embedded Studio and can be used with almost any Cortex-M4 device. The example for V10.4.3 and V11.0.1 are created specifically for the SEGGER Cortex-M Trace Reference Board. So if you want to use these projects on another hardware make sure to port the project accordingly. 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 process works similarly for all supported FreeRTOS versions.

Note: Up until V10 the kernel needs to be patched, while starting with V11 the instrumentation was added natively. So if you are using FreeRTOS V11 and later you can skipt the section "Patching". Above you can find different example projects.

Patching

  1. Get the patch file from the SystemView install directory (in the subdirectory "Src/Sample/*") for your corresponding FreeRTOS version
    • The patch for V10.4 may also be downloaded here
  2. Place it in the FreeRTOS/Source folder in your project
    • For Windows: You may use one of the available 3rd party patching tools, e.g. git or simply a manual patch
    • For Linux: Open the terminal at the location of the patch and call "patch -p1 -r . < FreeRTOS_10_4_3.patch"

Project configuration

  1. Get the required SystemView and RTT source files either
  2. Create a new folder in your project and Embedded Studio project explorer where to place the SystemView sources
    • For the reference example "/lib/SEGGER/SystemView" is used
  3. Add all SystemView Source files and folders to that folder according to the folder structure in SystemView source
  4. Add the same files to the Embedded Studio in the project explorer accordingly
  5. At the end of FreeRTOSConfig.h or before every "FreeRTOS.h" add #include "SEGGER_SYSVIEW_FreeRTOS.h"
  6. Add the include paths for the SystemView sources
    • They may be added using the 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.
    • "(ProjectDir)/lib/SEGGER/SystemView/SEGGER"
    • "$(ProjectDir)/lib/SEGGER/SystemView/Config"
    • "$(ProjectDir)/lib/SEGGER/SystemView/Sample/FreeRTOS"
  7. In case of using FreeRTOS V10 or older: Add the define "USE_LEGACY_TRACE_API=1"
  8. 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.
  • Unknown task names shown? Simply need to increase the value of SYSVIEW_FREERTOS_MAX_NOF_TASKS until all task names can be resolved. Keep in mind that FreeRTOS creates some tasks on its own so the number will be higher than the number of tasks that you created.
  • Task names truncated? You can set the maximum task name length with config define configMAX_TASK_NAME_LEN.