ThreadX with SystemView
Jump to navigation
Jump to search
This article describes how to use SystemView with Eclipse ThreadX RTOS.
Supported Software
SystemView has been tested with ThreadX V6.4.2.
Create a ThreadX project with Embedded Studio
- Start Embedded Studio.
- (optional) install CPU support Package for your device family via Tools->Package Manager.
- Set up a project for your hardware.
- Create new project via File -> New Project..., select Create the project in a new solution.
- Select the project template for your device. For example "A C/C++ executable for NXP LPC4300." and enter a project Name.
- Click Next and follow through the dialog.
- Test the created project.
- Connect your J-Link and the target hardware.
- Build the project with F7.
- Start a debug session with F5 and let it run.
- You should see the Hello World output in the Terminal window.
- Get ThreadX.
- Open the project in file explorer with File -> Open Studio Folder... -> Project Folder.
- Create a new folder 'threadx' and add the ThreadX sources to it.
- Use git to clone the threadx repository from https://github.com/SEGGERMicro/threadx
- Or download the latest release and extract it. For example https://github.com/SEGGERMicro/threadx/releases/tag/v6.4.2_rel-segger
- Add ThreadX to the Embedded Studio project.
- Create a new folder 'ThreadX' via right-click on the project -> New Folder....
- Create a new folder 'common' inside 'ThreadX' and set its Dynamic Folder Options.
- Set Source folder to '$(ProjectDir)/threadx/common'.
- Set Filter specification to '*.c;*.h'.
- Check 'Recurse into subdirectories'.
- Create a new folder 'ports' insode 'ThreadX' and set its Dynamic folder Options
- Set Source folder to the port of your target device. For example '$(ProjectDir)/threadx/ports/cortex_m4/gnu'.
- Set Filter specification to '*.s;*.S;*.c;*.h'.
- Set Exclude specification to '*example*'.
- Check 'Recurse into subdirectories'.
- Add include paths via righ-click on the project -> Options.
- Select 'Common' configuration (instead of 'Debug').
- Edit Code -> Preprocessor -> User Include Directories.
- Add '$(ProjectDir)/threadx/common/inc'.
- Add the include for your port. For example '$(ProjectDir)/threadx/ports/cortex_m4/gnu/inc'.
- (optional) Add third-party libraries, HALs, drivers, etc. to your project.
- Add your application code.
- Edit main.c to #include "tx_api.h" and replace main() with your code.
- Build, develop, and debug your project with Embedded Studio.
Add SystemView to your Project
The SystemView instrumentation needs to be added to the ThreadX sources. It is recommended to use the prepared ThreadX sources from https://github.com/SEGGERMicro/threadx, either the segger/master branch, or a release tagged with "*-segger".
If you are using ThreadX from another source, make sure to apply the modifications for instrumentation.
- Add the SystemView and RTT sources to the project
- Open the project in file explorer.
- Create a new folder 'SystemView' and add the SystemView sources to it.
- Use git to clone the latest version from https://github.com/SEGGERMicro/SystemView.
- or download the latest target sources from https://www.segger.com/downloads/systemview.
- Create a new folder 'RTT' and add the SEGGER_RTT sources to it.
- Use git to clone the latest version from https://github.com/SEGGERMicro/RTT.
- or use the sources from the latest SystemView target sources.
- Add the sources to your project.
- SystemView/SYSVIEW/*.c
- SystemView/SYSVIEW/Sample/ThreadX/SEGGER_SYSVIEW_ThreadX.c
- RTT/RTT/*.c
- RTT/RTT/*.s
- The SystemView Target Configuration. For example SystemView/SYSVIEW/Sample/ThreadX/Cortex_M4/SEGGER_SYSVIEW_Config_ThreadX.c.
- Add the include directories to your project.
- SystemView/Config
- SystemView/SEGGER
- SystemView/SYSVIEW
- RTT/Config
- RTT/RTT
- Configure SystemView and RTT for your target if necessary.
- Adjust SEGGER_SYSVIEW_Config_ThreadX.c to match your system.
- Set configuration in SEGGER_SYSVIEW_Conf.h.
- Set configuration in SEGGER_RTT_Conf.h.
- Enable ThreadX tracing with SystemView.
- Add preprocessor define ENABLE_TRACE_API=1.
- Add #include "SEGGER_SYSVIEW_ThreadX.h" at the end of tx_api.h.
- Call SEGGER_SYSVIEW_Conf(); in your main().