Help with building Jetson Xavier Kernel from sources

Hi, I am trying to build Jetson Kernel for Xavier from sources.
I downloaded JetPack_4.3_Linux_P2888, ran the script, synced all repos to tag tegra-l4t-r32.3.1,
Followed the steps in

Reflashes the jetson fully with sudo ./ jetson-xavier mmcblk0p1

And now the Jetson won’t boot into graphics target.
It’s stuck on Started Update UTMP about System Runlevel Changes
and before that there’s a Fail message about Failed to start nvpmodel service

I logged onto the Jetson though my host and I ran
systemctl status nvpmodel.service

Jere’s the ouptut:
● nvpmodel.service - nvpmodel service
Loaded: loaded (/etc/systemd/system/nvpmodel.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-04-11 17:49:50 UTC; 12min ago
Process: 6717 ExecStart=/usr/sbin/nvpmodel -f /etc/nvpmodel.conf (code=exited, status=234)
Main PID: 6717 (code=exited, status=234)

Apr 11 17:49:50 localhost.localdomain systemd[1]: Starting nvpmodel service...
Apr 11 17:49:50 localhost.localdomain nvpmodel[6717]: NVPM ERROR: Error opening /sys/devices/gpu.0/tpc_pg_mask: 2
Apr 11 17:49:50 localhost.localdomain nvpmodel[6717]: NVPM ERROR: optMask is 2, no request for power mode
Apr 11 17:49:50 localhost.localdomain nvpmodel[6717]: NVPM ERROR: Error writing quiet to /sys/bus/platform/devices/pwm-fan/fan_profile: 22
Apr 11 17:49:50 localhost.localdomain nvpmodel[6717]: NVPM ERROR: Fan failed to set mode:quiet
Apr 11 17:49:50 localhost.localdomain systemd[1]: nvpmodel.service: Main process exited, code=exited, status=234/n/a
Apr 11 17:49:50 localhost.localdomain systemd[1]: nvpmodel.service: Failed with result 'exit-code'.
Apr 11 17:49:50 localhost.localdomain systemd[1]: Failed to start nvpmodel service.

What am I doing wrong here?
I am really out of ideas what to do.

I would assume that some steps were missed before
Reflashes the jetson fully with sudo ./ jetson-xavier mmcblk0p1
How to reproduce the issue?

Hi Andrey,

Thanks for your reply.

So I run this script from inside the kernel source folder to compile the sources:

echo "[$(date +%H:%M:%S)] Building kernel and dtbs..."
start_time="$(date -u +%s)"

export TOOLCHAIN=$SOURCES/l4t-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin
export CROSS_COMPILE=${TOOLCHAIN}/aarch64-linux-gnu-
export LOCALVERSION=tegra
export KERNEL_OUT=$SOURCES/__kernel_build_output$

if [[ ! -e $KERNEL_OUT ]]; then
	mkdir $KERNEL_OUT
	echo "[$(date +%H:%M:%S)] Compiling clean kernel. This takes a while..."
	echo "[$(date +%H:%M:%S)] Recompiling..."

cd $SOURCES/kernel/kernel-4.9

echo "[$(date +%H:%M:%S)] Configuring kernel..."
make ARCH=arm64 O=$KERNEL_OUT tegra_defconfig >/dev/null 2>&1

echo "[$(date +%H:%M:%S)] Compiling kernel..."
make ARCH=arm64 O=$KERNEL_OUT CROSS_COMPILE=${CROSS_COMPILE} -j8 >/dev/null 2>&1

end_time="$(date -u +%s)"
echo "[$(date +%H:%M:%S)] Build took $(($end_time-$start_time)) seconds"

Once compiled, I do the following:
export JETPACK43=
cp $KERNEL_OUT/arch/arm64/boot/Image $JETPACK43/Linux_for_Tegra/kernel/Image
cp -r $KERNEL_OUT/arch/arm64/boot/dts $JETPACK43/Linux_for_Tegra/kernel/dtb

export INSTALL_MOD_PATH=$JETPACK43/Linux_for_Tegra/rootfs
sudo make ARCH=arm64 O=$KERNEL_OUT modules_install 

And then I run the command.

Oh, and before I reflash I run the script to create a default user that I can then use to ssh on the device (if necessary)

You may build it without cross-compiling, but directly at native Xavier environment. I used the latter approach.
May be more knowledgeable folks will add on the former.

Ok :) Thanks! I will try that! How long does it take to build natively? I use cross-compiling as it takes ~15 minutes on my desktop machine and I fear on the jetson it could take hours (at least the first run)

With Xavier, and if you use nvpmodel -m0 and jetson_clocks, it should take something like about 20 mins.
Be sure to start configuring your kernel with the config from running /proc/config.gz and customize later.

A couple of things to check…

Make sure your “.config” has correctly set the “CONFIG_LOCALVERSION”. Usually:


(otherwise the module may not be found)

And a tip, that if your “make” command is to use all CPU cores, then you must use the “-j#” option to “make”. Assuming you are on the Xavier with “sudo nvpmodel -m 0” to make 8 cores available (leaving out “ARCH” and toolchain locations if native to Xavier):

sudo make -j8 ...whatever else...

(if the system has 8 cores, then “-j8” will be nearly 8 times faster than without specifying)

Thank you so much @linuxdev! This was the problem all along. I had accidentally set
and missed the dash in the front… that I guess was causing all my problems as now that I added it everything seems to be in order.
Meanwhile I tried compiling on the Jetson, but the problem was the same (as I was using the same script I made for the Host, just dropped the cross compile part).

FYI, JetPack 4.3 installs Linaro 7.4 toolchain on the Jetson, so it’s not the recommended 7.3.1 that NVidia recommends for compiling the Linux Kernel . Just saying. Now I am once again compiling on the Host and everything seems to be in order.

Compile times on the host for me are ~1100 seconds and on the Jetson ~1200 seconds, so not much of a difference.

Thank you all for your help!

Just make sure you use the “-j #” depending on how many CPU cores you have. If you have eight cores, then “-j 8” is about eight times faster than the default (default being “-j 1”).

NOTE: If your system is using too much RAM, then a lower “-j #” would reduce memory required during compile.

Yep, thanks. I am already using -j8. The times I shared are with -j8