rt-patch on Jetson AGX Xavier

My Problem:

I applied the rt-patch.sh on the kernel sources and tried to flash to our Jetson AGX Xavier. Compiling the kernel works fine besides a few warnings but after the initial system configuration on the Xavier it hangs up while booting. I used the latest L4T Release package 32.2 and file system and latest public_sources. The last few lines before getting stuck when booting are:

Started nvpmodel service
Started ZRAM configuration
CPU4: shutdown
Started Argus daemon
CPU5: shutdown
Starting GNOME Display Manager…

After a few minutes when getting stuck it tries to reboot with the same result. Sometimes if it boots for the second or third or fourth time it boots into the OS successfully. This can take up to 20 minutes. Then when setting “nvpmodel -m 0” it takes a few minutes but seems to set the power-mode to MAXN. Rebooting with MAXN set doesn’t get stuck anymore but this is a very unclean solution. It seems like some race-condition with the nvpmodel service during boot to me.

My whole procedure looks like the following:

Download the L4T release package and sample file system for the Jetson Xavier from developer.nvidia.com/linux-tegra

Untar the L4T release package and sample file system:

mkdir $HOME/nvidia
cd $HOME/nvdia
sudo tar xpf ${L4T_RELEASE_PACKAGE}
cd Linux_for_Tegra/rootfs/
sudo tar xpf ${SAMPLE_FS_PACKAGE}

Download the public sources for Jetson Xavier and extract the kernel sources:

cd /where/you/downloaded/sources/
tar -xjf public_sources.tbz2
cd public_sources/
tar -xjf kernel_src.tbz2

Apply rt-patch:

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

Create cross-compilation environment:

mkdir $HOME/l4t-gcc
$ cd $HOME/l4t-gcc
Download toolchain from https://developer.nvidia.com/embedded/dlc/l4t-gcc-7-3-1-toolchain-64-bit
$ tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz  
export CROSS_COMPILE=$HOME/l4t-gcc/bin/aarch64-linux-gnu-

Build kernel

export TEGRA_KERNEL_OUT= /path/where/compiled/kernel/will/be/  
mkdir -p $TEGRA_KERNEL_OUT
cd /where/you/downloaded/sources/public_sources/kernel/kernel-4.9
make ARCH=arm64 O=$TEGRA_KERNEL_OUT CROSS_COMPILE=$CROSS_COMPILE tegra_defconfig
make ARCH=arm64 O=$TEGRA_KERNEL_OUT CROSS_COMPILE=$CROSS_COMPILE menuconfig 
A GUI menu will pop-up, select Timer Frequency 1000HZ, save, exit.
make ARCH=arm64 O=$TEGRA_KERNEL_OUT CROSS_COMPILE=$CROSS_COMPILE -j8
sudo cp $TEGRA_KERNEL_OUT/arch/arm64/boot/Image $HOME/nvidia/Linux_for_Tegra/kernel/Image
sudo cp -r $TEGRA_KERNEL_OUT/arch/arm64/boot/dts/* $HOME/nvidia/Linux_for_Tegra/kernel/dtb/
cd $HOME/nvidia/Linux_for_Tegra/
sudo ./apply_binaries.sh
cd /where/you/downloaded/sources/public_sources/kernel/kernel-4.9
sudo make ARCH=arm64 O=$TEGRA_KERNEL_OUT CROSS_COMPILE=$CROSS_COMPILE modules_install \
INSTALL_MOD_PATH=$HOME/nvidia/Linux_for_Tegra/rootfs/

Flash the Xavier

cd $HOME/nvidia/Linux_for_Tegra
sudo ./flash.sh jetson-xavier mmcblk0p1

I also tried all kinds of slightly different procedures suggested in several threads with the same result. What do you suggest to do differently?

Devices getting stuck due to schedutil governor which gives problem with RT Kernel.
By default performance governor is set in kernel. Please skip setting the schedutil governor during end of boot.

File: rfs/etc/systemd/nv.sh
@@ -130,6 +130,8 @@ if [ -e /sys/block/mmcblk1/queue/read_ahead_kb ]; then
echo 2048 > /sys/block/mmcblk1/queue/read_ahead_kb
fi

+IS_LINUX_RT=uname -rv | grep "PREEMPT RT" | wc -l
+
CPU_INTERACTIVE_GOV=0
CPU_SCHEDUTIL_GOV=0

@@ -146,7 +148,9 @@ if [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ]; \

    case $governors in
            *schedutil*)
  •                    CPU_SCHEDUTIL_GOV=1
    
  •                   if [ $IS_LINUX_RT -eq 0 ]; then
    
  •                           CPU_SCHEDUTIL_GOV=1
    
  •                   fi
       ;;
    
    esac