Jetson TX2 Compiling kernel

I am unable to cross compile L4T kernel following the instructions from NVIDIA Linux Tegra User Development Guide R32.2 (https://docs.nvidia.com/jetson/l4t/index.html) section Kernel Customization. I can reach step without errors but I am getting a number of errors running the following command.

sudo make ARCH=$ARCH O=$TEGRA_KERNEL_OUT -j2

Here is the error output:

HOSTLD  scripts/dtc/dtc
  CC      scripts/mod/empty.o
gcc: error: unrecognized command line option ‘-mlittle-endian’; did you mean ‘-fconvert=little-endian’?
/home/sctu/nvidia/nvidia_sdk/JetPack_4.2.1_Linux_GA_P3310/Linux_for_Tegra/sources/kernel/kernel-4.9/scripts/Makefile.build:297: recipe for target 'scripts/mod/empty.o' failed
make[3]: *** [scripts/mod/empty.o] Error 1
/home/sctu/nvidia/nvidia_sdk/JetPack_4.2.1_Linux_GA_P3310/Linux_for_Tegra/sources/kernel/kernel-4.9/scripts/Makefile.build:548: recipe for target 'scripts/mod' failed
make[2]: *** [scripts/mod] Error 2
/home/sctu/nvidia/nvidia_sdk/JetPack_4.2.1_Linux_GA_P3310/Linux_for_Tegra/sources/kernel/kernel-4.9/Makefile:576: recipe for target 'scripts' failed
make[1]: *** [scripts] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/sctu/nvidia/nvidia_sdk/JetPack_4.2.1_Linux_GA_P3310/Linux_for_Tegra/kernel/the_source3'
Makefile:170: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

Host System:
PC: ASUS i86_64 Processor
OS: UBuntu 18.04
Jetpack: 4.2.1
L4T: 4.9
Make: built for x86_64-PC-Linux-GNU
Toolchain: Linaro 7.3.1 2018.05

Target System
Jetson TX2 with arm64 processor

My hypothesis for this error has something to do with endianess of the host v target processor. Any thoughts before I head down this rabbit hole.

Thanks in advance.

  • Chris

You probably shouldn’t be using sudo, but technically it won’t harm anything. You also need to specify a cross compiler prefix, which I don’t see in your command.

Let’s say you have installed the “aarch64-linux-gnu-*” tools. This would name a location:

which aarch64-linux-gnu-gcc

If this turned out to be “/usr/bin/aarch64-linux-gnu-gcc”, then the prefix is:

/usr/bin/aarch64-linux-gnu-

You could set this as an environment variable:

export CROSS_COMPILE=/usr/bin/aarch64-linux-gnu-
export ARCH=arm64
export TEGRA_KERNEL_OUT=/some/where
# make sure kernel is configured...
make O=$TEGRA_KERNEL_OUT -j2 Image
make O=$TEGRA_KERNEL_OUT -j2 modules

You could put it in one line:

CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- ARCH=arm64 make O=$TEGRA_KERNEL_OUT -j2 Image
CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- ARCH=arm64 make O=$TEGRA_KERNEL_OUT -j2 modules

If you create an image on a VM can you use that image to flash the TX2?

Thanks,
Ben

The Image is any arm64/aarch64/ARMv8-a kernel (see the “kernel customization” section of the documents). Doesn’t matter where you create it. Typically the Image itself is just a file copy not requiring flash (don’t forget to save the original Image). You can put the Image in the right place of the “Linux_for_Tegra/kernel/” content and use it, but this is way more complicated than just a file copy.

VMs are not an issue for application development, nor are VMs an issue for kernel compiling. VMs are not supported for flashing, but they can be made to work if you’re willing to go through whatever is needed to make sure the VM owns the USB completely and does not lose USB each time USB disconnects and reconnects.