About real time kernel patch

We want to do the real time kernel patch,and we found that in the path “kernel/kernel-4.4” ,there is a directory “rt-patches”.
Do I need to patch all patches in the “rt-patches”?
Or I just go to https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.4/older/ to get the “patch-4.4.38-rt49.patch.xz” ?

I have not tried to add this, but generally speaking (and thus could be generally wrong), the “patch 4.4.1” files were applied to a 4.4.1 kernel. The 4.4.102 patch files were applied to kernel 4.4.102, so on. If you are using a 4.4.38 kernel, then you’d want the patches at or before 4.4.38. The exception is if you are back porting from a newer kernel. In some cases that could make sense, but if for example the patch is to a feature which did not exist in 4.4.38, then it would not make sense.

Also note that some patches from an earlier kernel might have made their way into mainline. In that case applying the earlier patch to 4.4.38 would fail (you can’t add a patch which is already patched).

I am just guessing, but most likely you want to at least start with all patches prior to the 4.4.102 patches.

Thanks for your reply.
also thanks for kozyilmaz,I can get the real-time kernel.

 just do this:
cd kernel/kernel-4.4
     for i in rt-patches/*.patch; do patch -p1 < $i; done

but,there is no information about real-time driver programming,there are all real-time application programming.
Does anyone know how to write a kernel thread at a real-time kernel?

Hi XuXiang,

Did you succeeded in applying the patch without any rejection ?



I am trying to apply the real-time patches to my Jetson Tx2. I was curious if there are more detailed instructions for help, similar to the ones for the Nano at this post:

specifically, after the compilation, with the Jetson Tx2 I need to flash the board rather than create an SD card.


Hi ashraf.wahba,

To install the latest L4T 32.4.3 on Jetson TX2 with real-time patches, you can follow this instructions:

Install required packages

sudo apt-get update
sudo apt-get install libncurses5-dev
sudo apt-get install build-essential
sudo apt-get install bc
sudo apt-get install lbzip2
sudo apt-get install qemu-user-static
sudo apt-get install python

Create folder

mkdir $HOME/jetson_tx2
cd $HOME/jetson_tx2

Download required files

L4T Jetson Driver Package:

wget https://developer.nvidia.com/embedded/L4T/r32_Release_v4.3/t186ref_release_aarch64/Tegra186_Linux_R32.4.3_aarch64.tbz2

L4T Sample Root File System:

wget https://developer.nvidia.com/embedded/L4T/r32_Release_v4.3/t186ref_release_aarch64/Tegra_Linux_Sample-Root-Filesystem_R32.4.3_aarch64.tbz2

L4T Sources:

wget https://developer.nvidia.com/embedded/L4T/r32_Release_v4.3/sources/T186/public_sources.tbz2

GCC Tool Chain for 64-bit BSP:

wget http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz

Extract files

sudo tar xpf Tegra186_Linux_R32.4.3_aarch64.tbz2
cd Linux_for_Tegra/rootfs/
sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R32.4.3_aarch64.tbz2
cd ../../
tar -xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
sudo tar -xjf public_sources.tbz2
tar -xjf Linux_for_Tegra/source/public/kernel_src.tbz2

Apply real-time patches

cd kernel/kernel-4.9/
./scripts/rt-patch.sh apply-patches

Configure and compile the kernel

export CROSS_COMPILE=$HOME/jetson_tx2/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
make ARCH=arm64 O=$TEGRA_KERNEL_OUT menuconfig

Configure the next options:

General setup -> Timer subsystem -> Timer tick handling -> Full dynticks system (tickless)
Kernel Features -> Preemption Model: Fully Preemptible Kernel (RT)
Kernel Features -> Timer frequency: 1000 HZ

The script that applies the real-time patches disables the CPU idle driver, however, jetson_clocks also tries to disable this feature and you can see an error when running jetson_clocks. To avoid that, you can enable it again:

CPU Power Management -> CPU idle -> ARM CPU Idle Drivers -> CPU Idle Driver for NVIDIA Tegra 18x SoCs

make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4

sudo cp jetson_tx2_kernel/arch/arm64/boot/Image $HOME/jetson_tx2/Linux_for_Tegra/kernel/Image
sudo cp -r jetson_tx2_kernel/arch/arm64/boot/dts/* $HOME/jetson_tx2/Linux_for_Tegra/kernel/dtb/
sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$HOME/jetson_tx2/Linux_for_Tegra/rootfs/

cd $HOME/jetson_tx2/Linux_for_Tegra/rootfs/
sudo tar --owner root --group root -cjf kernel_supplements.tbz2 lib/modules
sudo mv kernel_supplements.tbz2  ../kernel/

cd ..
sudo ./apply_binaries.sh

Flash the Jetson TX2

Put Jetson TX2 in recovery mode and then flash it:

sudo ./flash.sh jetson-tx2 mmcblk0p1

To finish, install Jetson SDK components using NVIDIA SDK Manager

Best regards!