
In the design process of RTOS applications, the task switching is managed by the RTOS task scheduler, and the source code of the RTOS application cannot fully reflect the real-time behavior of a multitasking system. The real-time behavior of a multitasking system also depends on tasks, interrupts, inputs, and their interactions. Therefore, the real-time behavior of RTOS applications is not very intuitive for developers. At this point, an RTOS visualization analysis tool like SystemView can be used to help analyze the actual execution process of the application.
SystemView is an embedded system visualization analysis tool developed by SEGGER, providing complete insights into applications, including timelines, CPU load, runtime information, context runtime information, and other visualization windows, helping developers gain an in-depth understanding of application runtime behavior. SystemView supports μC/OS-II, μC/OS-III, FreeRTOS, embOS, and bare-metal systems without OS.
This article will introduce how to use Segger SystemView based on the official μC/OS-III port example on the STM32F767ZI_Nucleo development board, including adding device-side SystemView related application code and setting up the PC-side SystemView software. The version of μC/OS-III used is V3.07.03. The ST-Link on the STM32F767ZI_Nucleo development board can be updated to J-Link using the STLinkReflash software provided by Segger. SystemView supports three operating modes, and in the continuous recording mode, SystemView can record the target execution situation in real-time while the target program runs. This article will demonstrate how to use SystemView to trace μC/OS-III using the onboard J-Link debugger and SEGGER Real-Time Transfer technology (RTT).
01
Adding SystemView and RTT Implementation Code on the Target Device
(1) To use SEGGER SystemView, you first need to add the SystemView and RTT source files to the target application project. The source package for SystemView and RTT is provided in the installation directory of the PC-side SystemView software.

The source code includes three parts:
1) Configuration files for SystemView and RTT real-time transfer technology: modifications may be needed based on application requirements.
2) Specific implementation source code for SystemView and RTT technology: typically, no modifications are needed here.
3) Interface files corresponding to various types of OS and different OS versions: select the corresponding interface file based on the actual application situation. In this article, we choose to add the corresponding files under the uC/OS-III directory.
After adding the aforementioned configuration files, RTT implementation source code, and OS interface files to the project, the included files in the project are as follows. Note that you also need to set the include paths for these newly added C files and assembly code files in the IDE.

(2) Perform some configurations related to SystemView
• In the os_cfg.h file, set the tracking function of μC/OS-III to 1 to enable it.
#define OS_CFG_TRACE_EN 1u
• Add header file inclusion in the application code main.c file
#include “os_trace.h”
• Configure the maximum number of tasks and other kernel objects in os_cfg_trace.h

In the SEGGER_SYSVIEW_Config_uCOSIII.c file, configure the system clock frequency, timestamp counter frequency, and the base address of the chip’s RAM. If the project uses the HAL library, you can use the functions provided in the HAL library to return these parameter values.

• Set the size of the event buffer in SEGGER_SYSVIEW_Conf.h
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 1024
The size of the buffer space here needs to be determined based on the J-Link debug interface rate and the number of events recorded. When the J-Link rate is low or the number of recorded events is large, a larger buffer space should be set. When using SystemView Single-Shot mode, memory should be increased to record for as long as possible.
(3) Call the SystemView initialization function before creating tasks
After completing the hardware initialization of the chip, call the OS_TRACE_INIT() function to initialize SystemView before creating μC/OS tasks.

02
Installation and Setup of PC-side SystemView Software
The PC-side SystemView software can be downloaded from the Segger official website, the download link is as follows:
https://www.segger.com/downloads/systemview/
(1) To utilize J-Link for continuous recording with SystemView, you need to set the target chip model, target debug interface type (JTAG/SWD), and interface speed in the Target->Recorder Configuration option of the SystemView software.
For the RTT control block address detection, choose Auto; typically, it can be successfully detected by J-Link automatically.


(2) After completing the Recorder Configuration settings, click Target->Start Recording to start the tracking. In the demonstration, J-Link was used, and the default tracking mode is continuous recording mode, where the start and stop of tracking will be controlled by the PC-side SystemView software.
After entering tracking, you can obtain a visual tracking view as shown in Figure 6, where each column represents an interrupt or Task in the application, arranged in order of priority from high to low. Figure 6 intuitively shows the situation of task preemption occurring in the RTOS application, where the low-priority DemoTask is preempted by the high-priority TestTask during execution.

By utilizing visualization analysis tools like SystemView, developers can better understand the real-time behavior of RTOS applications, thereby creating higher quality code. The official μC/OS-III port example used in this demonstration on the STM32F767ZI_Nucleo development board can be downloaded from the following link,https://www.weston-embedded.com/micrium-examples/category/230-stm32f7
If you need a commercial license for the SystemView software, please contact[email protected]
Welcome to follow the WeChat public account 【麦克泰技术】, reply “Join Group” to join the technical exchange group as prompted
Product Consultation:
Beijing: 010-62975900
Shanghai: 021-62127690
Shenzhen: 0755-82977971