Xenomai 4 Realtime Kernel for Edge2 (Ubuntu 24.04) - Development Test Release

Hello Folks,

We are excited to announce that the Xenomai4 realtime kernel for Ubuntu 24.04 is now available for Edge2. You can install it online using OOWOW.

  • Edge2: edge2-ubuntu-24.04-gnome-linux-xenom-fenix-1.7.3-250604-develop-test-only.img.xz

U-Boot Version: 2024.07

NOTE: This is a development test release, not a final version. Please be aware of potential bugs and report any issues you encounter.

We highly encourage your feedback!


Test EVL

Dependencies Installed

Clone repos

cd ~
git clone https://github.com/khadas/linux.git
cd linux/
git checkout khadas-linux-xenomai4-6.12.y
cd ../
git clone https://source.denx.de/Xenomai/xenomai4/libevl.git

We have installed all required packages and Python modules to support EVL kernel development and testing:

sudo apt update
sudo apt install -y \
  build-essential meson ninja-build pkg-config libbpf-dev libelf-dev \
  libdw-dev libclang-dev clang cmake libnuma-dev python3 python3-pip \
  python3-setuptools libcap-dev
pip3 install ninja --break-system-packages

CPU Isolation Configured

To ensure low-latency and deterministic performance for EVL real-time threads, CPUs 4 and 5 have been isolated:

  • Modified /boot/extlinux/extlinux.conf:
APPEND ... isolcpus=4,5 nohz_full=4,5 rcu_nocbs=4,5
  • System rebooted to apply changes.

(Optional) Minimum CPU frequency set for real-time cores:

echo 1800000 | sudo tee /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq
echo 1800000 | sudo tee /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq

EVL Library Compiled and Installed

Compiled EVL from source using Meson and Ninja:

mkdir /tmp/build-native && cd /tmp/build-native
meson setup -Dbuildtype=release -Dprefix=/usr -Duapi=~/linux . ~/libevl
meson compile
sudo ninja install

Functionality Verified

Ran the EVL test suite:

sudo evl test
basic-xbuf: OK
clock-timer-periodic: OK
clone-fork-exec: OK
detach-self: OK
duplicate-element: OK
element-visibility: OK
...

All core tests passed successfully (e.g., monitor-pi, poll-xbuf, sched-tp-accuracy, etc.).


Real-Time Context Switch Stress Test (hectic)

Executed the hectic tool to validate context switching and FPU management under stress:

sudo hectic -s 200
  • Threads successfully spawned across isolated CPUs.
  • FPU test routines passed.
  • Real-time scheduling results were observed and validated.

Real-Time Performance Test on Edge2 with Xenomai4

Platform: Khadas Edge2
Kernel: 6.12.19+ PREEMPT EVL
libevl version: evl.0.50 -- #c39165f
Test Duration: 3 hours continuous
CPU Affinity: CPU5 (isolated)
Thread Priority: 98
Sampling Period: 1000 µs
Context: User space

System Stress Conditions

To simulate a real-world multitasking scenario, system stress was introduced using the following methods:

Memory and CPU stress:

stress -m 16 -c 16

GPU/Graphics stress:
Launched glmark2-es2-wayland on 4 separate terminals.

Latency Results (from evl-latency)

Metric Value
Min latency -2.417 µs
Avg latency -1.845 µs
Max latency 7.674 µs
Total samples 10,828,298
Peak load time 02:17:09
Total test duration 03:00:29

Observation: Under full system load (CPU, memory, GPU), the real-time EVL thread on CPU5 maintained an impressively low maximum latency of just 7.674 microseconds.

Self build

In fenix , replace the Linux branch as following shows:

diff --git a/config/boards/Edge2.conf b/config/boards/Edge2.conf
index a0680292..0550845b 100644
--- a/config/boards/Edge2.conf
+++ b/config/boards/Edge2.conf
@@ -96,7 +96,7 @@ case "$LINUX" in
                [ "$LINUX_VENDOR_DIR" ] && \
                LINUX_DIR=$(realpath "$LINUX_VENDOR_DIR")
                LINUX_DTB="$LINUX_DIR/arch/arm64/boot/dts/rockchip/rk3588s-khadas-edge2.dtb"
-               LINUX_GIT_BRANCH="khadas-linux-6.12.y"
+               LINUX_GIT_BRANCH="khadas-linux-xenomai4-6.12.y"
                LINUX_DEFCONFIG="${LINUX_DEFCONFIG:-kedges_defconfig}"
                SERIALCON="ttyS2"
                BOOT_SCRIPT_BOARD=""

Then build Edge2 mainline image.

2 Likes