Skip to content

Instantly share code, notes, and snippets.

@bspguy
Last active January 8, 2024 08:25
Show Gist options
  • Save bspguy/b5200984cee621c1ec86cd2e296c8a8b to your computer and use it in GitHub Desktop.
Save bspguy/b5200984cee621c1ec86cd2e296c8a8b to your computer and use it in GitHub Desktop.
Apply Linux rt-patch to Petalinux
1. Find your kernel version according to the kernel Makefile. Example:
# SPDX-License-Identifier: GPL-2.0
VERSION = 6
PATCHLEVEL = 1
SUBLEVEL = 0
EXTRAVERSION =
NAME = Hurr durr I'ma ninja sloth
2. Clone the correct tag from github into <plnx-proj-root>/components/linux-xlnx-rt/:
git clone https://github.com/Xilinx/linux-xlnx.git
3. According to your kernel version download the equivalent rt-patch version from:
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/
4. Copy the *-patch.gz file to <plnx-proj-root>/components/linux-xlnx-rt folder.
5. cd linux-xlnx-rt
6. Patch the kernel sources by running: zcat ../*.patch.gz | patch -p1
7. Run petalinux-config and set:
linux Components Selection -> linux-kernel and change option from linux-xlnx to ext-local-src
linux Components Selection-> External linux-kernel local source settings-> <plnx-proj-root>/components/linux-xlnx-rt
8. Save and exit configuration.
9. Run petalinux-config -c kernel and set:
General setup -> Timers subsystem "High Resolution Timer Support"
General Setup menu and to--> Preemption Model
Select "Fully Preemptive Kernel (RT)"
Kernel Features -> select Timer frequency and set it to 1000 Hz
CPU power Management -> Disable the CPU frequency scaling
10. Save configuration and exit.
11. Clean project: petalinux-build -x mrproper
12. Build just the kernel with no errors:
petalinux-build -c kernel
13. Build all: petalinux-build
14. Following boot, <uname -a> command should output SMP PREEMPT_RT in kernel title.
<Based on https://www.hackster.io/LogicTronix/real-time-optimization-in-petalinux-with-rt-patch-on-mpsoc-5f4832>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment