Applying a PREEMPT-RT patch to JetPack 4.5 on Jetson Nano

Hi @trueshadow97, this is the guide updated for JetPack 4.5 (L4T 32.5):

Real-time Linux for Jetson Nano (L4T 32.5)

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_nano
cd $HOME/jetson_nano

Download required files

L4T Jetson Driver Package:

wget https://developer.nvidia.com/embedded/L4T/r32_Release_v5.0/T210/Tegra210_Linux_R32.5.0_aarch64.tbz2

L4T Sample Root File System:

wget https://developer.nvidia.com/embedded/L4T/r32_Release_v5.0/T210/Tegra_Linux_Sample-Root-Filesystem_R32.5.0_aarch64.tbz2

L4T Sources:

wget https://developer.nvidia.com/embedded/L4T/r32_Release_v5.0/sources/T210/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 Tegra210_Linux_R32.5.0_aarch64.tbz2
cd Linux_for_Tegra/rootfs/
sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R32.5.0_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

TEGRA_KERNEL_OUT=jetson_nano_kernel
mkdir $TEGRA_KERNEL_OUT
export CROSS_COMPILE=$HOME/jetson_nano/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

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

make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4

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

cd $HOME/jetson_nano/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

Generate Jetson Nano image

cd tools
sudo ./jetson-disk-image-creator.sh -o jetson_nano.img -b jetson-nano -r 300

For Jetson Nano 2GB version use -b jetson-nano-2gb-devkit

The -r 300 switch is the revision number of the Jetson Nano module to be used:
100 for revision A01
200 for revision A02
300 for revision B00 or B01
Nothing for Jetson Nano 2GB or Jetson Xavier NX (do not use the -r switch)

Reference: https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html#wwpID0E0TJ0HA

The resulting image is: $HOME/jetson_nano/Linux_for_Tegra/tools/jetson_nano.img

Flash the image to the micro SD card using Etcher
Use the micro SD to boot the Nano with monitor, mouse and keyboard
Follow the steps for first boot setup
To finish, install CUDA and the rest of Jetson SDK components using SDK manager

I successfully generated a working image for my Jetson Nano following these instructions. Please let me know if you have any issues.

Best regards