Real-time System Test on OK3568-C Single Board Computer
In Industry 4.0, artificial intelligence and Industrial Internet of Things have developed rapidly. More and more industries have needs for real-time operating systems. Therefore, Forlinx Embedded has launched a real-time operating system for OK3568-C SBC. This article will introduce the way Forlinx Embedded realizes real-time performance on OK3568-C SBC, and test of the real-time kernel.
OK3568-C Single Board Computer Pic
1. Why use a real-time operating system?
Operating systems can be divided into real-time operating systems and time-sharing operating systems. Time-sharing operating system switches system processor time and memory space to the programs of each end user in turn at a certain time interval. At present, Linux systems running on majority of boards on market are time-sharing operating systems. However, with the rise of industries such as autonomous driving and intelligent robots, higher requirements are also placed on real-time performance of onboard operating system. Therefore, time-sharing system cannot meet the needs of some industries that require high real-time performance. Linux must be improved to have better real-time performance to conform to the development of industry.
For example, in driverless technology, system needs to analyze and judge in a timely manner according to complex road conditions, and perform braking or lane-changing; another example is car airbag. In event of an accident, system must respond immediately to eject airbags and protect passengers in vehicle. These application scenarios are inseparable from real-time operating system.
2, How to achieve "real-time"?
Linux can be patched to achieve "real-time". RT-Linux is to add a real-time patch to Linux, thereby improving Linux into a real-time operating system. Real-time patching is to improve the priority inversion, spin lock and other issues of Linux to meet the requirements of real-time operating systems.
Based on this idea, we can make the Linux on RK3568 SBC meet real-time requirements by adding a real-time patch in kernel.
Forlinx provides two patch files:
Copy the two patch files to source code/OK3568-linux-source/kernel, and execute following command:
patch-p1 < 0002-fix-kernel-sched-core.c.patch
Then, execute ./build.sh kernel on source code to generate boot.img image in /OK3568-linux-source/kernel.
Users can also directly flash the boot.img image made by Forlinx in single step.
Use Type-C cable to connect RK3568 SBC and host. Press and hold Recover key, then press reset key, and release recover key after about two seconds. The system will prompt to discover a loader device.
Click "Device Partition Table", the partition address will be automatically read.
Click to check boot partition on left.
Finally, click on the right to select the path of boot image generated by your compilation, and click "Execute" to automatically flashing and restart RK3568 SBC.
To learn more about RK3568 real-time patching, you can contact Forlinx Embedded Sales Engineer online.
3. Real-time kernel test
The key indicator for real-time performance is "latency", which refers to the time it takes for system to respond to an event when an event occurs, no matter where system is running in code. Interrupt delay refers to the time from interrupt trigger to completion of execution of interrupt service function; scheduling delay refers to the time that process waits in queue until CPU control is obtained and executed. Real-time performance can also be reflected as the maximum tolerance for these two delays. Here, interrupt delay and scheduling delay time are measured by cyclictest.
The delay statistics measured by running cyclictest without a suitable load are meaningless since the maximum delay time cannot be triggered in a real usage environment. Here we use official hackbench tool to simulate some types of loads, and then run cyclictest on this basis to test the time that system responds to the event when it occurs.
Test results of RK3568 without real-time patch:
Test results of RK3568 with real-time patch:
Here we focus on comparing the parameters obtained by Max. Because real-time performance of system is determined by maximum delay time. By comparing test results with and without real-time patch, it can be clearly seen delay is reduced from 213μs to less than 80μs. (The delay under different test conditions is different. The test results here are for reference only)