PREEMPT-RT patches for Jetson Nano

Nothing from Nvidia - they’ve gone silent. I moved to a RaspberryPi 4/4GB to get my project going - preempt-RT patch was already live on that platform back in October (despite only being out for a few months). Benefit of having a true open platform, is that your customers can work at their own development pace and share the results, rather than waiting for schedule to become available on the expensive/busy employees behind a closed source product and NDAs.

I’m also going to go out on a limb as predict that the “big news” from Nvidia in the media as of late is not going to be better platform support.

Seems to work now

:~$ uname -a
Linux jetson-desktop 4.9.140-rt93 #2 SMP PREEMPT RT Sat Dec 21 17:10:21 EET 2019 aarch64 aarch64 aarch64 GNU/Linux

Idle system cyclictest

:~$ sudo cyclictest -t 5 -p 80 -n

/dev/cpu_dma_latency set to 0us

policy: fifo: loadavg: 0.04 0.07 0.08 1/308 7012

T: 0 ( 6995) P:80 I:1000 C: 54894 Min: 4 Act: 6 Avg: 5 Max: 22
T: 1 ( 6996) P:80 I:1500 C: 36596 Min: 5 Act: 6 Avg: 5 Max: 18
T: 2 ( 6997) P:80 I:2000 C: 27447 Min: 5 Act: 6 Avg: 5 Max: 22
T: 3 ( 6998) P:80 I:2500 C: 21957 Min: 5 Act: 6 Avg: 5 Max: 19
T: 4 ( 6999) P:80 I:3000 C: 18298 Min: 5 Act: 6 Avg: 6 Max: 15

system loaded with iperf3 and ping -f

~$ sudo cyclictest -t 5 -p 80 -n

/dev/cpu_dma_latency set to 0us

policy: fifo: loadavg: 0.43 0.29 0.17 2/308 7114

T: 0 ( 7038) P:80 I:1000 C: 313656 Min: 4 Act: 7 Avg: 7 Max: 52
T: 1 ( 7039) P:80 I:1500 C: 209104 Min: 5 Act: 6 Avg: 7 Max: 48
T: 2 ( 7040) P:80 I:2000 C: 156828 Min: 5 Act: 7 Avg: 7 Max: 54
T: 3 ( 7041) P:80 I:2500 C: 125462 Min: 5 Act: 7 Avg: 7 Max: 52
T: 4 ( 7042) P:80 I:3000 C: 104552 Min: 5 Act: 6 Avg: 7 Max: 34

Please tell me how you achieved that. I still have the bootloop after uboot loaded the kernel…

I’m running without X11

sudo systemctl enable multi-user.target
sudo systemctl set-default multi-user.target

and I did build kernel on the target which is terribly slow

apply rt patches
cd kernel-4.9/scripts

./rt-patch.sh apply-patches

make menuconfig

enable rt_full preemption

make -j4 Image

make -j4 modules

backup old kernel
sudo cp /boot/Image /boot/Image.original

sudo make modules_install

sudo cp arch/arm64/boot/Image /boot/Image

sudo make headers_install INSTALL_HDR_PATH=/usr

Hi everyone,

I confirm that with the release of JetPack 4.3 - L4T R32.3.1 now the Jetson Nano is working OK with the PREEMPT-RT patches. Here are the steps I followed in my Ubuntu laptop to generate the image for my Jetson Nano:

# Install required packages
sudo apt-get update 
sudo apt-get install libncurses5-dev 
sudo apt-get install build-essential bc 
sudo apt-get install lbzip2
sudo apt-get install qemu-user-static

# Create build folder
mkdir $HOME/jetson_nano 
cd $HOME/jetson_nano 

# Download the following files in the jetson_nano folder:

# L4T Jetson Driver Package
https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/t210ref_release_aarch64/Tegra210_Linux_R32.3.1_aarch64.tbz2

# L4T Sample Root File System
https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/t210ref_release_aarch64/Tegra_Linux_Sample-Root-Filesystem_R32.3.1_aarch64.tbz2

# L4T Sources:
https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/Sources/T210/public_sources.tbz2

# GCC Tool Chain for 64-bit BSP
https://developer.nvidia.com/embedded/dlc/l4t-gcc-7-3-1-toolchain-64-bit

# Extract files
sudo tar xpf Tegra210_Linux_R32.3.1_aarch64.tbz2 
cd Linux_for_Tegra/rootfs/ 
sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R32.3.1_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 PREEMPT-RT patches
cd kernel/kernel-4.9/ 
./scripts/rt-patch.sh apply-patches 

# Compile 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 

# This option should already be selected:
Kernel Features -> Preemption  Model: Fully Preemptible Kernel (RT)

# You can modify other options for your kernel, like the timer frequency (or anything you need):
Kernel Features -> Timer frequency: 1000 HZ 

# After saving the configuration and exiting, start the kernel compilation
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4 

# Copy results
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/ 

# Apply binaries
cd .. 
sudo ./apply_binaries.sh

# Generate Jetson Nano image
cd tools
sudo ./jetson-disk-image-creator.sh -o jetson_nano.img -s 14G -b jetson-nano -r 100

After this, I flashed the jetson_nano.img file into my SD card and booted the Jetson Nano with it. The board booted without problems.

IMPORTANT: After booting it is necessary to install CUDA and the rest of components using NVIDIA SDK Manager.

sorry but following this last post, its not working as written

line #29 fails tar -xjf Linux_for_Tegra/source/public/kernel_src.tbz2

after poking around, i found i had to run ./source_sync.sh to even get the kernel tree

Hi scottkvps23,

You are right, there was some information missing but I just modified my previous comment. You also need to download the L4T sources and extract:

#L4T Sources:
https://developer.nvidia.com/embedded/dlc/r32-3-1_Release_v1.0/Sources/T210/public_sources.tbz2

sudo tar -xjf public_sources.tbz2

Sorry for my mistake, I already modified my previous post.

Best regards

so… i did finally build the image based on the directions, i dd’d it to the sdcard, when trying to boot… it just sits at the NVIDIA LOGO forever… any ideas… this is the Nvidia NANO Devkit, prior to the release kit.

Hi scottkvps23,

I don’t know if it will make a difference, but I used Etcher to flash the SD card. To validate the instructions I repeated the whole process again and my image is working, as you can see in the picture:

Is that another version of the Nano board? If that is the case, you can look for the correct -r number for your board when generating the image:

sudo ./jetson-disk-image-creator.sh -o jetson_nano.img -s 14G -b jetson-nano -r 100

I used -r 100, but in the documentation (https://docs.nvidia.com/jetson/l4t/index.html) you can see all the valid options:

[i]To generate an image to be flashed to an SD card:

./jetson-image-disk-creator.sh -o <blob_name> -s <blob_size> -b -r

Where:
<blob_name> is a filename; the script saves the raw image with this name.

<blob_size> specifies the size of the blob. It is a number suffixed with an optional unit code, for example, 3120M. The unit code may be:
G for GiB
M for MiB
K for KiB
B bytes (the default if no unit is specified)

specifies the type of Jetson device the SD card is to be flashed for. Because an SD card currently may be used only to boot Jetson Nano, the value of must be jetson-nano.

is the revision number of the Jetson Nano module to be used:
100 for revision A01
200 for revision A02
300 for revision B00 lr B01
[/i]

Best regards
nano.png

Hi everyone,

Does JetPack 4.3-L4T R32.3.1 support PREMPT-RT?
I want to run PREMPT-RT on Nano board.

Best regards

Hi bokyung86sky,

Yes, JetPack 4.3 - L4T 32.3.1 supports the PREEMPT-RT patches for the Jetson Nano board. Follow this instructions to compile and create the SD image:

https://devtalk.nvidia.com/default/topic/1050012/jetson-nano/preempt-rt-patches-for-jetson-nano/post/5413865/#5413865

What version of the Jetson Nano Kit do you have? It’s important to know that because you need to specify the correct revision with the -r option in the line:

sudo ./jetson-disk-image-creator.sh -o jetson_nano.img -s 14G -b jetson-nano -r 100

For example, for the latest Jetson Nano Kit, the correct revision is -r 300.

Best regards
Real-time_Linux_for_Jetson_Nano_.pdf (132 KB)

Hi,
I’ve followed the instructions for making the new kernel and everything goes fine until the line “make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j4”, at which point I get an error message “~/jetson_nano/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc cannot execute binary file” it also mentions that the elf was not found. There are however files in the above mentioned directory including gcc.
I’ve tried this a few times using the nano itself and also using an intel desktop with Debian wheezy and I have gotten the same errors from both machines at the same point.
I notice that the installation was done on an unbuntu laptop so before I change the desktop to Unbuntu (16.04.6 lts xenial xerus 32 bit pc i386 image), I was wondering if there is anything else I should do first or is it necessary to do this from an unbuntu machine?
thanks

Hi preprec377x,

In the Nano you are getting that error because you are trying to execute the cross-compilation toolchain in an ARM architecture, while the toolchain is for the x86_64 architecture. In Debian I guess it should work, but your Debian system must be amd64. You have a few options, like compiling in the Nano without the CROSS_COMPILE variable (however, it can take a long time), getting the correct toolchain for your Debian architecture here: http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/, or following the steps in the guide using Ubuntu 64 bits.

Best regards

Hi ajcalderont,

Many thanks for your answer. I’ll try the nano option without the cross_compile line first since my debian system is not amd64.

thanks again

Hi ajcalderont,
Been following your guide with some alterations since I had to perform the kernel compilation on a hard drive (didn’t have enough space in my root filesystem). On the step
sudo ./apply_binaries.sh
I am getting the following error:

||||||||||||||||||||||| ERROR |||||||||||||||||||||||
-----------------------------------------------------
1. The root filesystem, provided with this package,
   has to be extracted to this directory:
   /media/shadow97/8C8A90B58A909CF0/jetson_nano/Linux_for_Tegra/rootfs
-----------------------------------------------------
2. The root filesystem, provided with this package,
   has to be extracted with 'sudo' to this directory:
   /media/shadow97/8C8A90B58A909CF0/jetson_nano/Linux_for_Tegra/rootfs
-----------------------------------------------------
Consult the Development Guide for instructions on
extracting and flashing your device.
|||||||||||||||||||||||||||||||||||||||||||||||||||||

Any suggestions? As far as I can tell, the root filesystem has been extracted to the rootfs directory. Previous steps worked fine.

Hi ajcalderont, I followed your steps and successfully installed the PREEMPT RT patches. Since I want to use WiFi for the jetson nano, I plan to install a wifi package from here. When I download it and do a " make defconfig-iwlwifi-public" command, it shows an error:

/--------------
| Your kernel headers are incomplete/not installed.
| Please install kernel headers, including a .config
| file or use the KLIB/KLIB_BUILD make variables to
| set the kernel to build against, e.g.
| make KLIB=/lib/modules/3.1.7/
| to compile/install for the installed kernel 3.1.7
| (that isn’t currently running.)

Is that possible due to the rt kernel? How to fix this? Thanks!

Hi @zhb7991, I am not sure if this can help, but you can try putting -tegra in the local version in the “menuconfig” screen:

General setup → Local version → -tegra

The bad news is that to try this, you will need to recompile the kernel.

Best regards

Does the PREEMPT-RT change the behavior of preemption of the GPU? For jetson nano “maxwel,” there is no preemption. This feature was available in the pascal line, and what follows? Or is this PREEMPT-RT just for CPU scheduling?