Building a Real-Time Petalinux Kernel for AMD Xilinx Devices
In the field of defense, accuracy and speed are of the utmost importance.

Building a Real-Time Petalinux Kernel for AMD Xilinx Devices

The world of technology is constantly evolving, and real-time computing is becoming an increasingly critical aspect of many applications. In the field of defense, accuracy and speed are of the utmost importance. Real-time computing is an essential requirement for many applications, where the accuracy and speed of operations are critical. In aerospace and defense, real-time computing is especially important as the systems must respond to threats quickly and accurately. A delay of even a few seconds can result in significant damage and loss of life. This is why the defense industry is constantly seeking out new ways to improve the performance and reliability of their systems.

No alt text provided for this image
DornerWorks embedded engineer Taylor Prins.

With real-time computing, it is possible to achieve high levels of precision and accuracy in a short amount of time, making it a valuable tool in many areas, from air-traffic control to medical systems and beyond. A major defense contractor wanted to meet this goal, but also wanted to leverage their existing Linux software stack, so DornerWorks engineers applied the Linux real-time patch to a AMD Xilinx Petalinux kernel to provide better real-time behavior for their application.

Building the Kernel

The kernel version to be used was v2021.1. First, the Xilinx source code of the kernel was cloned at the ‘xlnx_rebase_v5.10_2021.1’ tag. The PREEMPT_RT patch version must be matched specifically to the linux kernel version being used. Since the petalinux 2021.1 kernel being build uses the 5.10 linux kernel, the correct patch was obtained here:?https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.10/older/patch-5.10-rt17.patch.gz

Other patch versions are available if using a different linux kernel version here:

https://wiki.linuxfoundation.org/realtime/preempt_rt_versions

To apply the patch the following command was used from within the linux-xlnx folder:

zcat //patch-5.10-rt17.patch.gz | patch -p1        

The ZCU102 development board uses a zynqmp processor. To build the defconfig for the kernel, the following command was used:

make ARCH=arm64 xilinx_zynqmp_defconfig        

Beyond the PREEMT_RT patch itself, several kernel configuration changes are also needed. Once the defconfig was built, `make menuconfig` was used to open the kernel configuration GUI. The following changes were necessary:

General setup —> Preemption Model —> Fully Preemptible Kernel (Real-Time)

Kernel features —> Timer frequency —> 1000 HZ

CPU Power Management —> CPU Frequency scaling —> (Disable)

With the kernel changes made, the kernel can now be built using the following:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-        

Once the kernel finishes building, the kernel image can be found in here: ./arch/arm64/boot/Image

Benchmarking the Kernel

Paired with the newly created PREEMPT_RT petalinux 2021.1 kernel was a petalinux 2021.1 rootfs (built prior using petalinux tools) that contained both the ‘rt-test’ and ‘stress-ng’ application packages. Adding these applications to the project are accomplished by following the petalinux tools guide here:?https://docs.xilinx.com/r/2021.1-English/ug1144-petalinux-tools-reference-guide/Adding-an-Existing-Recipe-into-the-Root-File-System. These software packages allowed for the use of ‘cyclictest’ and ‘stress’ applications for benchmarking. The benchmarking procedure was the following for each test:

  1. Boot the kernel and rootfs in a ramdisk environment (ie… not using persistent storage).
  2. Start the stress application in the background as follows:

stress --cpu 4 --io 4 --vm 2 --vm-bytes 128M &        

3. Start a cyclictest iteration and pipe its data to a file for 1 million cycles as follows:

cyclictest --clock=1 --mlockall --nanosleep --priority=80 --verbose --loops=1000000 > testdata.dat        

Once each test was finished, the output data file was copied to a development machine for post processing.

Benchmarking Results

The gathered data was clear and concise that the real-time kernel was in fact working properly. This can be seen in the vastly lower worst-case latencies observed during the cyclictest runs. Comparison of the data can be seen below.

Baseline (without PREEMPT_RT)

Figure 1: Cyclictest data of Petalinux 2021.1 w/o PREEMPT_RT
Figure 1: Cyclictest data of Petalinux 2021.1 w/o PREEMPT_RT
Figure 2: Cyclictest data of Petalinux 2021.1 w/o PREEMPT_RT – Zoomed
Figure 2: Cyclictest data of Petalinux 2021.1 w/o PREEMPT_RT – Zoomed

RT_PREEMPT patch applied

No alt text provided for this image
Figure 3: Cyclictest data of Petalinux 2021.1 w/ PREEMPT_RT patch applied
No alt text provided for this image
Figure 4: Cyclictest data of Petalinux 2021.1 w/ PREEMPT_RT patch applied – Zoomed


A foundation for real-time systems innovation

This project has provided valuable insights and a baseline comparison for future customers who want to run real-time applications using Linux. Developing real-time systems that stand out and deliver the accuracy and precision your customers require can be difficult, but new technologies shouldn’t hold you back. DornerWorks can help you leverage Linux as a license free soft real-time operating environment for your timing sensitive applications.?Schedule a meeting?with our team and we will help you turn your ideas into reality.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了