OK3588 6.1.118 Buildroot PREEMPT_RT Real-Time Patch Application and Performance Testing
by yir65681 in Circuits > Microcontrollers
9 Views, 0 Favorites, 0 Comments
OK3588 6.1.118 Buildroot PREEMPT_RT Real-Time Patch Application and Performance Testing
In industrial control, motion control, machine vision, edge data acquisition, and other application scenarios, the system must not only run but also operate on time. In scenarios that require high determinism in response, standard Linux often struggles to meet strict real-time requirements related to scheduling latency and interrupt response. As a result, enhancing real-time performance on Linux platforms has become a key focus for many developers.
This article provides a comprehensive overview of the acquisition, porting, compilation adaptation, and real-time verification of the PREEMPT_RT real-time patch on the OK3588 Buildroot platform, along with actual testing processes. Real-time performance before and after applying the patch is compared using cyclictest. The results indicate that the maximum scheduling latency of the system is significantly improved in both idle and stress scenarios.
How to Obtain the Real-Time Patch for the OK3588 Platform?
For the OK3588 platform, the SDK provides the PREEMPT_RT patch corresponding to the relevant version.
The path includes several patch files related to real-time performance, such as the foundational RT patch, scheduler isolation optimizations, memory configuration adjustments, additional real-time kernel configurations, and USB-related fixes, among others.
It is important to note that applying PREEMPT_RT is not a simple task of "apply one patch and you're done." Since the preemption points of the real-time patch are distributed throughout nearly the entire kernel, chip manufacturers often need to adjust some underlying drivers accordingly. Therefore, from an engineering perspective, it is more reliable and easier to implement patch sets that have already been curated by chip manufacturers or platform providers, rather than using generic upstream RT patches directly.
How to Port the Real-Time Patch to the Buildroot Kernel?
According to the workflow outlined in the documentation, porting the real-time patch for the OK3588 6.1.118
Batch Application of Patches in the Kernel Directory
First, navigate to the kernel directory and use the patch command to import the real-time patch files provided in the SDK.
Supplementing and Saving the Corresponding Kernel Configuration Items
After entering the patch, you also need to add the corresponding CONFIG item.
Operation on the menu is performed by pressing the ''/'' key to search for the PREEMPT option, then pressing 1 to enter it.
Navigate further into the submenu, select the highest real-time priority level, and proceed to compile.
Return to the Top-level SDK Directory and Perform a Full Compilation
After configuration is complete, return to the top-level SDK directory and execute ./build.sh to compile the entire system.
tips:
Encountering errors during compilation is common, as different SDKs incorporate various drivers that may not be adapted to the modifications introduced by the real-time patch.
For instance, by examining the changes made to specific functions within the real-time patch, clues about the issue can often be identified.
As observed in the real-time patch, the function `u64_stats_fetch_begin_irq` has been completely replaced by `u64_stats_fetch_begin`. By referencing this modification from the real-time patch and making the corresponding adjustments to the driver, the compilation was successful, allowing the firmware to be flashed for testing.
Real-Time Performance Testing
Download the compressed package and place it on the development board. Execute the command `tar -xvf rt-tests-2.2.tar -C /` to extract the contents into the root directory. The `cyclictest` tool will then be available in `/usr/bin/`.