Operations 15 min read

How to Build, Patch, and Benchmark a Real‑Time Linux Kernel on the OK3588 Board

This guide explains the purpose of the PREEMPT‑RT real‑time patch, describes the hardware and toolchain used, details the kernel features and modifications introduced by the patch, and provides step‑by‑step instructions for downloading, applying, configuring, compiling, flashing, and verifying the real‑time kernel with cyclictest and stress‑ng benchmarks.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Build, Patch, and Benchmark a Real‑Time Linux Kernel on the OK3588 Board

Introduction

Linux PREEMPT‑RT (real‑time) patches provide deterministic low‑latency behavior for time‑critical workloads such as industrial control, audio processing and robotics.

Test environment

Hardware: Feiling OK3588 development board

Kernel source: 5.10.66‑rt53

Build host: Ubuntu 20.04 LTS

Toolchain: aarch64‑linux‑gnu‑

Key features of the PREEMPT‑RT patch

Low latency – faster response to external events.

High‑priority scheduling – real‑time tasks can run with the highest priority.

Full preemption – real‑time threads can preempt kernel code, including long‑running sections.

Lock optimizations – spinlocks are replaced by rt_mutex with priority inheritance, reducing priority inversion.

High‑resolution timers – nanosecond‑level timer precision.

Interrupt threading – interrupts are handled in kernel threads, preventing them from blocking real‑time tasks.

Installing and building a PREEMPT‑RT kernel

Download kernel source

wget https://www.kernel.org/pub/linux/kernel/vX.Y/linux-X.Y.Z.tar.xz

Download matching RT patch from https://www.kernel.org/pub/linux/kernel/projects/rt/ Apply the patch

tar -xf linux-X.Y.Z.tar.xz
cd linux-X.Y.Z
patch -p1 < /path/to/patch-rt-X.Y.Z.patch

Configure the kernel make menuconfig Enable Preemption ModelFully Preemptible Kernel (RT) and select other real‑time options.

Compile and install

make -j$(nproc)
make modules_install
make install

Flash the new kernel (example for the OK3588 board) ./upgrade_tool di -b boot.img Reboot and verify the running kernel contains the -rt suffix.

Verification with cyclictest

Check the kernel version: uname -r Install the rt‑tests suite:

git clone git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
cd rt-tests
git checkout stable/v1.0
make -j$(nproc) && sudo make install

Run cyclictest to measure worst‑case latency. Example command (1 000 000 loops, priority 99, FIFO policy, 25 ms interval):

cyclictest -l 1000000 -m -Sp99 --policy=fifo -h 25000 -q >output.txt

Parameter description: -l 1000000 – number of test loops. -m – run in real‑time mode with detailed output. -Sp99 – set thread priority to 99 using SCHED_FIFO. --policy=fifo – explicit FIFO scheduling. -h 25000 – test interval of 25 ms. -q – quiet mode, only final statistics.

Test scenarios

No RT patch – idle load – set all CPUs to the performance governor and run cyclictest.

No RT patch – full CPU load – start a 24 h stress‑ng workload on 8 threads (

stress-ng -c 8 --cpu-method fft --timerfd-freq 1000000 -t 24h &

) then run cyclictest.

With RT patch – idle load – repeat the idle‑load steps after flashing the RT kernel.

With RT patch – full CPU load – repeat the full‑load steps after flashing the RT kernel.

In all cases the maximum latency observed with the RT‑patched kernel is lower than without the patch.

Typical application domains

Industrial automation – fast control loops.

Audio processing – low‑latency DSP.

Robotics – rapid sensor‑actuator feedback.

Time‑sensitive networking – deterministic packet handling.

Conclusion

The PREEMPT‑RT patch can be applied to a standard Linux kernel, configured via make menuconfig, built and deployed to the target board. Latency measurements with cyclictest under both idle and stressed conditions demonstrate a clear reduction in worst‑case latency, confirming deterministic real‑time performance.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

EmbeddedReal-Time KernelcyclictestPREEMPT_RTstress-ng
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.