
How to Apply the Linux-RT Real-time Patch in the T113 Embedded System?
In order to improve the response performance of the T113 embedded platform in real-time control scenarios, a PREEMPT-RT real-time patch (patch-5.4.61-rt37) needs to be applied to the Linux 5.4.61 kernel. It can optimizes the kernel scheduling mechanism and improves task response determinism, serving as a critical tool for embedded systems to achieve "soft real-time" or "firm real-time" performance.
Environmental Description
- Platform: Allwinner T113(OK113i)
- Kernel version: Linux 5.4.61
- Development environment: Based on OK113i Linux SDK (including kernel and buildroot)
- Goal: Integrate Linux-RT real-time patches into the kernel and validate real-time performance.
1. Download and extract the patch-5.4.61-rt37 patch
patch-5.4.61-rt37.patch.gz
The uname -a command reveals that the T113 platform runs Linux kernel version 5.4.61, which allows downloading the corresponding RT real-time patch from the official Linux-RT repository at:
Index of /pub/linux/kernel/projects/rt/5.4/older/
2. Extract the downloaded patch-5.4.61-rt37.patch file and place the decompressed patch into the linux5.4 directory, as shown in the following project path:
3. Execute the following command in the linux5.4 directory to apply the patch to the kernel: How to Apply Kernel Patches with patch Command-CSDN Blog
4. Due to code discrepancies, the system will report numerous mismatches causing patch application failure. The following command can be used to identify failed patch files:
Then, according to the directory prompt, find the file that failed to enter the patch. Manually integrate it.
5. To enable the real-time system configuration in the kernel, open the menu configuration. The temporary .config file for the T113 is located in the OK113i-linux-sdk/out/kernel/build directory. Therefore, you need to run make menuconfig ARCH=arm in that directory.
The related configuration is as follows:
After completing the modification, save and exit.
Since the configuration file saved in OK113i-linux-sdk/out/kernel/build is only temporary, you need to copy the .config file to the kernel configuration directory:
OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/, and rename it to sun8iw20p1smp_t113_auto_defconfig.
Then, perform a full kernel compilation based on this updated configuration.
Next Step: Add the rt-tests Tool in Buildroot
To add the rt-tests utility to Buildroot:
First, modify the Kconfig file located at OK113i-linux-sdk/kernel/linux-5.4/drivers/cpufreq/Kconfig to add the corresponding configuration option (checkbox).
Next, add the box selection in the figure in OK113i-linux-sdk/kernel/linux-5.4/init/Kconfig
After modification, switch to the path in the code box below to open the interface settings.
The relevant modification steps are shown in the figure below:
When the modification is complete, save and exit. Then compile under the current path.
After successful compilation, switch to the SDK path for full compilation.
After the compilation is successful, pack the image and burn it to the T113, and then describe below the relevant tests in the serial port terminal.
Real-time test: cyclictest-Zhihu (zhihu. com)
Input the following commands in the serial port terminal to test.
Plain Text copy the code.
1 2 cyclictest -l10000000 -m -n -t3 -p99 -i2000 -h100 // Or execute: cyclictest -t 5 -p 80 -n // Launches 5 threads at priority 80 with endless iteration.
Test data when no real-time patch is applied.
After comparison, it is found that the delay of T113 with linux-rt real-time patch is reduced to about 60 microseconds, while the maximum delay of T113 without linux-rt real-time patch is 9482 microseconds.