How to compile the TX2 L4T kernel source?

Hi,erverybody,
I try to compile the TX2 L4T kernel source,but there are many many errors occurred.I doubt my compile method is wrong.
My question:Is there a guide like this https://developer.ridgerun.com/wiki/index.php?title=Compiling_Tegra_X1_source_code for TX2?
Thanks

There is this:
http://www.jetsonhacks.com/2017/03/25/build-kernel-and-modules-nvidia-jetson-tx2/

Most of the mechanics here for the TX1 are the same, but no kernel bug edits are needed:
https://devtalk.nvidia.com/default/topic/936880/jetson-tx1/jetson-tx1-24-1-release-need-help-with-complier-directions-can-not-complie/post/4885136/#4885136

Hi,linuxdev

I need to cross compile a kernel but modules.The article seems a local compile guide but not cross compile.

This is my cross compile method.Is there some wrong in it?

1.cd the source directory

cd ~/kernel/kernel-4.4

2.Excute the cmds

export DEVDIR=$PWD && mkdir -p $DEVDIR/images/modules && mkdir -p $DEVDIR/images/packages
export CROSS_COMPILE=/home/lyp/tx2_source/compiler/bin/aarch64-unknown-linux-gnu-
export ARCH=arm64 && export TEGRA_KERNEL_OUT=$DEVDIR/images/package

3.compile

make mrproper
make tegra18_defconfig
make

Then some wrongs occured.

CC      drivers/../../t18x/drivers/platform/tegra/nvadsp/dev-t18x.o
In file included from drivers/../../t18x/drivers/platform/tegra/nvadsp/dev-t18x.c:22:0:
drivers/platform/tegra/nvadsp/dev.h:32:22: fatal error: dev-t18x.h: 没有那个文件或目录
 #include "dev-t18x.h"
                      ^
compilation terminated.
make[5]: *** [drivers/../../t18x/drivers/platform/tegra/nvadsp/dev-t18x.o] 错误 1
make[4]: *** [drivers/../../t18x/drivers/platform/tegra/nvadsp] 错误 2
make[3]: *** [drivers/../../t18x/drivers/platform/tegra] 错误 2
make[2]: *** [drivers/../../t18x/drivers/platform] 错误 2
make[1]: *** [drivers/../../t18x/drivers] 错误 2
make: *** [drivers] 错误 2

but i do find this head file in the sources.

cd ..
find .-name dev-t18x.h
./t18x/drivers/platform/tegra/nvadsp/dev-t18x.h

lots of head file not found but it do exits.

Is my compile method wrong or the source code has many issue?

You do also need this (listed in the TX1 compile instructions, it applies to TX2 as well):

export CROSS32CC=/where/ever/cross-armhf/gcc

The ARMv8 architecture has a 32-bit compatibility mode…compile will probably fail for main kernel without CROSS32CC set. Try the TX1 instructions, they work for me (I’ve been using Linaro 5.3 compilers). I’ve also been using the “/proc/config.gz” for my initial config, but tegra18_defconfig should also work.

Hi,linuxdev

I try,it still error.

I think this is not related to the compiler

Since the file is in the “t18x/” subdirectory of sources, but not in the kernel, I am wondering if something has configured a feature using this which my kernel build is not referencing (my kernel build works, yours doesn’t, so either config or sources differ). I downloaded the sources manually through the web page and the directory tree upon unpacking had t18x and kernel-4.4 as subdirectories (my compile commands are always issued from the “kernel-4.4” subdirectory):

> ls
display/  kernel-4.4/  nvgpu/  nvgpu-t18x/  nvhost/  nvhost-t18x/  nvmap/  nvmap-t18x/  t18x/

Nothing in the kernel source should reference the t18x subdirectory unless there is something custom going on. Does anyone know what might trigger a kernel dependency on the t18x subdirectory?

Hi,linuxdev

Could you give me the address that you download the sources ? And your config file.

Thank you very much.

Hi CalmCar, Have you refer to “Advanced Setup and Customization”->“Building the NVIDIA Kernel” section in https://developer.nvidia.com/embedded/dlc/l4t-documentation-27-1 .

Hi,vickyy

I have refer to the “Advanced Setup and Customization”->“Building the NVIDIA Kernel” section.But it has no information about the lost files.It just mention the env about compile.

I downloaded from the R27.1 page:
https://developer.nvidia.com/embedded/linux-tegra

At the bottom of that page is “Source Packages”->“Sources”. This is what I used (unpacking this tar file provides kernel source plus several other related source). My config was from the “/proc/config.gz” as initial config.

Hi CalmCar,

Please make sure your toolchain and export setting are correctly.
List steps for you reference.

Toolchain:

1. Download gcc-4.8.5-aarch64.tgz
2. tar gcc-4.8.5-aarch64.tgz

Environment variables:

$ export CROSS_COMPILE=/home/Desktop/TX2_R27.1_build-kernel/install/bin/aarch64-unknown-linux-gnu-
$ export TEGRA_KERNEL_OUT=/home/Desktop/TX2_R27.1_build-kernel/Linux_for_Tegra/out
$ export ARCH=arm64

Build the Tegra Kernel

$ cd  kernel/kernel-4.4
$ make O=$TEGRA_KERNEL_OUT tegra18_defconfig
$ make O=$TEGRA_KERNEL_OUT zImage
$ make O=$TEGRA_KERNEL_OUT dtbs
$ make O=$TEGRA_KERNEL_OUT modules
$ make O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=<your_destination>

Please let us know your result. Thanks!

Hi,ererybody

I solve this problem.
Because the Makefile.* not include the head file path.Add it and it works.

For example:

this error

In file included from drivers/../../t18x/drivers/platform/tegra/nvadsp/dev-t18x.c:22:0:
drivers/platform/tegra/nvadsp/dev.h:32:22: fatal error: dev-t18x.h: 没有那个文件或目录
 #include "dev-t18x.h"

vim …/t18x/drivers/platform/tegra/nvadsp/Makefile.t18x

add follow

ccflags-y += -I../t18x/drivers/platform/tegra/nvadsp/

Thanks