[Xianji RT-Thread BSP misc series] systemview visual RTOS debugging
I. Introduction
Happy Labor Day! ! !
Xianji released the RT-Thread BSP v1.5.0 version at the end of April 2024. The portal is as follows:
RT-Thread BSP v1.5.0 released | Optimizing the ecosystem
First of all, the RT-Thread BSP directory structure is relatively clear. You can download the bsp of the relevant board in rtthread studio. This article mainly downloads the bsp of HPM6800EVK. After downloading in rtthread studio, you can find the bsp package in the repo in the installation directory of the software. ,as follows:
A relatively new update in BSP v1.5.0 is the addition of misc. The misc directory under common currently contains three main projects. Currently, it mainly supports RTOS visual debugging, interrupt vector mode in RTOS and preemptible Interrupt support.
The full name of misc is Miscellaneous (miscellaneous). Just as the literal meaning means, it is used to describe elements, components or configurations that are not easy to be classified into specific categories. They do not directly belong to the main functional modules of the system, but are indispensable, such as configuration parameters and auxiliary debugging. tools etc.
Regarding the use of systemview on the riscv platform, especially under the RT-Thread platform, a general description of the transplantation work has been made in previous articles. The portal is as follows:
[hpm_application] RT-Thread application execution visual analysis: SystemView is here!
This component happened to be supported in BSP V1.5.0 first, and I also tried it when it was released. I will explain the relevant experience in using it. The official transplant ideas are not within the scope of this article. You can cooperate with the above articles and The official code will be analyzed, especially the interrupt processing, and will be supplemented in subsequent articles.
Effect:
2. Operation process
It mainly operates commonly used configurations. For other configuration applications, please refer to segger's systemview manual.
(1) New construction projects
You can create any example in BSPv1.5.0. This article takes the Ethernet example ethernet_demo as an example. It should be noted that systemview is a product of Segger and needs to be debugged with Jlink, so it is best to choose jlink as the debugger.
(2) menuconfig configuration
In the official example, systemview is closed by default and developers need to open it according to their needs. The location of the setting in rtthread studio is as follows:
The corresponding menuconfig location of env is as follows:
The README.md document is also provided in the systemview folder for a simple introduction to use. This article is also based on the readme for operation and use.
1. Enable segger systemview
As shown in the figure above, if you need to use systemview, you need to enable it yourself. After enabling it, the following configuration will appear and it will be automatically enabled.
2. systemview RTT section
Systemview relies on Jlink's RTT module, so in addition to setting the section of systemview, you also need to set the section of the RTT module. The official default is to place it on nocache so that the data is affected by the cache. In addition, systemview does not provide API registration for cache operations. It is recommended to use the official original section configuration
3. MCU related parameter configuration
Mainly set the name of the application (App name), device name (device supported by jlink), Timestap freq (time stamp frequency), cpu freq (CPU frequency), system description (system descriptor).
(1)CPU device config
The official default is HPM6750xVMx.
For other advanced models, you can find them in the device list of jlink, or of course in the application J-flash.
Portal: https://www.segger.com/supported-devices/hpmicro/
For the HPM6800EVK board used in this article, the MCU used is HPM6880IBD1, and the corresponding Jlink device name is HPM6880xBDx
(2) frequency config
The timestamp used by systemview is the cycle of the CPU, and the frequency is exactly the frequency of the CPU. Both are 500MHz.
(3) system description 0~2
System descriptor mainly describes the interrupt name, the format is "I#num=name", num is the interrupt label, name is the interrupt name.
For example, in the mchtmr mentioned above, the interrupt number here is 2055. The example in this article is Ethernet. You can start an Ethernet interrupt. From the um manual, we know that the interrupt number of ENET0 is 92.
Since then, the configuration information of HPM6800EVK is as follows:
4. segger RTT config
Mainly configure the number of channels of the RTT module, the number of bytes of input and output channels, etc. Just keep the default, the number of channels can be set to 3, the channel used by systemview is 2, and channel 0 is used as the serial port device of rtthread.
5. systemview buffer config
It mainly configures the RTT module channel and Buffer size used by systermview. The Buffer size here defaults to 2048. If the tracking requirements are relatively large, such as turning on rtthread related object information tracking and multiple thread scheduling, larger adjustments are required. The example in this article uses Ethernet, iperf will be turned on, and there is enough ram space, so the size is set to 100K, which is 102400
6. systemview rtthread hook register
rtthread provides system and interrupt hook functions. Systemview obtains relevant information in the hook function and sends it to play a tracking role.
The systemview component also opens the registration of different hooks to monitor kernel objects and interrupts. Just use the component default here.
3. PC systemview verification
(1) Preparation work
1. After modifying the parameters, save the configuration, compile, and then burn.
2. Download the systemview software from the segger official website. The latest version can be used.
https://www.segger.com/downloads/systemview
3. Convert the project’s
libraries\misc\systemview\SystemView_Description\SYSVIEW_RTThread.txt' Copy to the Description folder in the systemview installation directory
(2) Configuration
1. To view the log information printed on the MCU side, you need to remember two pieces of information, one is the CPU frequency, and the other is the buffer address of the RTT module.
2. Open the systemview software and select the recorder configuration in the target.
3. In the pop-up window, select the default: J-Link.
4. For target connection, select the SOC model corresponding to the board. From the above, we know that the SOC is HPM6880xBDx. For RTT Control Block Detection, select the address of the above log information. After the configuration is completed, select OK.
5. Click the recording start button prompted in the upper left corner to start recording.
(3) Analyze system information
1.system
(1) Mainly record the target MCU information, such as SOC model, SOC frequency, and timestamp cycle frequency .
(2) Recording records the running time, the number and frequency of event occurrences, and the number of Overflow Buffer overflows.
(3) Analysis mainly records the captured size, peak throughput, and parsing speed.
(4) Record the number of threads, switching times and time. The number of interruptions, the number of times they occur.
2. events timeline
Mainly record the sequence number of each event, the timestamp of the event, the context of the event, the event name, and the specific event.
Take the led_th thread in the example as an example. The thread will flash the LED light at 500ms
(1) In systemview, you can see that the interval from the last LED flash to the next flash is exactly 500ms. 773-272=501ms.
(2) Let’s first analyze the before and after scheduling of led_th.
At this moment, the mchtmr timer interrupt occurs, and the clock beat of the bsp's rtthread is timed by mchtmr.
After the timer is interrupted, the rt_tick_increase API will be used to schedule the time slice rotation.
That is 6.9us in the picture. It takes about 6.9us to schedule led_th in the time slice. The dispatch to led_th took 4.3us.
Then there is the task run of led_th, which is to execute the lighting event. After taking 3.6us, delay is used and the scheduler is given up.
(3) cpu load rate
Here you can also view the load distribution of the CPU
For more information and analysis, please view segger's systemview manual.
4. Summary
1. Xianji adapts the systemview component, which can help developers deeply understand the related behaviors of Xianji MCU running in rtthread and analyze runtime data, including task scheduling, interrupt activities, system events, etc., by viewing the time consumed by the operation, improve Troubleshooting efficiency and performance.