Building kernel 5.10 from script

When I am building the kernel from script inside /Linux_for_Tegra/sources/ I get the below errors from NVIDIA drivers.

/home/shreyas/Projects/Jetson_porting/sources/kernel/nvidia/drivers/pinctrl/pinctrl-tegra186.c:434:4: error: ‘const struct tegra_pingroup’ has no member named ‘preemp_bit’
434 | .preemp_bit = e_io_hv,
| ^~~~~~~~~~
/home/shreyas/Projects/Jetson_porting/sources/kernel/nvidia/drivers/pinctrl/pinctrl-tegra186.c:693:3: note: in expansion of macro ‘PIN_PINGROUP_ENTRY_Y’
693 | PIN_PINGROUP_ENTRY_Y(r, bank, pupd, e_io_hv, e_lpbk,
| ^~~~~~~~~~~~~~~~~~~~
/home/shreyas/Projects/Jetson_porting/sources/kernel/nvidia/drivers/pinctrl/pinctrl-tegra186.c:752:2: note: in expansion of macro ‘PINGROUP’
752 | PINGROUP(dap4_sclk_pcc0, I2S4, RSVD1, RSVD2, RSVD3, 0x2048, 0, Y, -1, -1, 6, -1, 9, 10, -1, 12, Y, -1, -1, Y),
| ^~~~~~~~
/home/shreyas/Projects/Jetson_porting/sources/kernel/nvidia/drivers/pinctrl/pinctrl-tegra186.c:435:4: error: ‘const struct tegra_pingroup’ has no member named ‘rfu_in_bit’
435 | .rfu_in_bit = 20,
…and so on

Any inputs on this?

Download sources package and follow document steps to build the kernel, replaced nvgpu.ko , Image and install kernel modules then full flash image, after boot up, the DP display can show up without problem.

Download Bootlin Toolchain gcc 9.3 from: Jetson Linux 34.1 | NVIDIA Developer

  • Setting the CROSS_COMPILE_AARCH64 path:
    $ export CROSS_COMPILE=$HOME/l4t-gcc/bin/aarch64-buildroot-linux-gnu-

Are you building from the tar archives or from the git sources? I’m able to build the kernel cleanly from the git sources (running I’ve yet to diff the tar archives to the git sources. My build fails in the dtbs due to missing dtsi files – I’m guessing some symlink is missing.

To prove I have an Image:
bob@booger:/disk1/nvidia/nvidia_5.0_preview/kernel-5.10-src$ find . -name Image
bob@booger:/disk1/nvidia/nvidia_5.0_preview/kernel-5.10-src$ ls -lt ./build_output/arch/arm64/boot/Image
-rw-rw-r-- 1 bob bob 33567232 Apr 27 07:57 ./build_output/arch/arm64/boot/Image

Yes using I’m able to get the kernel sources. And following Kernel build procedure from Kernel Customization — Jetson Linux<br/>Developer Guide 34.1 documentation, I am able to build it. But facing some issues while when I used a build script
/home/shreyas/Projects/Jetpack5.0/sources/kernel/nvidia/drivers/iommu/arm-smmu-t19x.c:52:10: fatal error: linux/dma-attrs.h: No such file or directory
52 | #include <linux/dma-attrs.h>
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
scripts/ recipe for target ‘drivers/iommu/arm-smmu-t19x.o’ failed
make[2]: *** [drivers/iommu/arm-smmu-t19x.o] Error 1
make[2]: *** Waiting for unfinished jobs…
CC drivers/iommu/arm-smmu-regs.o
/home/shreyas/Projects/Jetpack5.0/sources/kernel/nvidia/drivers/iommu/arm-smmu-regs.c:21:10: fatal error: arm-smmu-regs.h: No such file or directory
21 | #include “arm-smmu-regs.h”
| ^~~~~~~~~~~~~~~~~
I think the driver files inside sources/kernel/nvidia/drivers are not properly updated yet.

I’m unclear here. To clarify things, you got the unmodified, as shipped sources from git to build cleanly, both kernel and dtbs? Now you have modified something and it doesn’t build?

Don’t forget, this is the 5.10 kernel. Some features and files from the 4.9 kernel have been dropped or the code refactored. File include/linux/dma-attrs.h doesn’t exist in the stock 5.10 kernel or the nvidia 5.10 kernel. It does in the 4.9 nvidia kernel (I didn’t check the stock 4.9 kernel).

Yes I have a build script developed for downloading toolchain, compiling kernel source, building dtb’s, kernel modules and rootfs. And this script file actually calls internally for building Linux kernel. Apart from that no modifications are done. Toolchain, rootfs everything seems to be fine but errors are faced when building kernel. The same script was used for 32.6 L4T and worked fine before.

Any changes to the “stock” defconfig you are using?
How did you get the “stock” dtbs to build completely? That’s the error I’m hitting.
I’m trying to get the “as shipped” code to build before I start tweaking. The one thread about the missing symlink was helpful:

Another thought. Did you diff your dot-config from the working build to the dot-config from the failing build script? Are there any changes? arm-smmu-t19x.c doesn’t look like it will successfully build in the 5.10 kernel due to header changes.

The “stock” dot-config (which is from the tegra-defconfig) doesn’t have CONFIG_TEGRA_ARM_SMMU_T19x enabled. This driver needs to be ported to the 5.10 kernel. Looking at the upstream 5.10 linux kernel source, dma-attrs.h was deleted on August 3, 2016.
bob@booger:/disk1/nvidia/nvidia_5.0_preview/kernel-5.10-src$ grep -E CONFIG_TEGRA_ARM_SMMU_T19x ./build_output/.config

# CONFIG_TEGRA_ARM_SMMU_T19x is not set
1 Like

Thank you for the input, The macro “CONFIG_TEGRA_ARM_SMMU_T19x” is missing in tegra_defconfig. Since I am using a custom defconfig where the macro is eanbled throws this error.
CONFIG_ARM_SMMU_DEBUG=y enabling this macro avoids the below error, fatal error: linux/arm-smmu-debug.h: No such file or directory.
Also there are few more compilation errors
nvidia/drivers/clk/tegra/clk-nv-bpmp.c:632:13: error: passing argument 1 of ‘IS_ERR’ makes pointer from integer without a cast [-Werror=int-conversion]
632 | if (IS_ERR(clk_debugfs_add_file(hw, “fmon_clamp_rate”,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sources/kernel/nvidia/drivers/clk/tegra/clk-nv-bpmp.c:632:13: error: implicit declaration of function ‘clk_debugfs_add_file’ [-Werror=implicit-function-declaration]
632 | if (IS_ERR(clk_debugfs_add_file(hw, “fmon_clamp_rate”,
| ^~~~~~~~~~~~~~~~~~~~

I changed defconfig to default “tegra_defconfig”, and I am now able to see dtsi missing errosr as you addressed.
arch/arm64/boot/dts/Makefile:79: recipe for target ‘arch/arm64/boot/dts/ddot/ddot/ddot/ddot/ddot/ddot/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-as-p3769-p3737-0000-dsi-tianma-a-dphy.dtb’ failed
make[1]: *** [arch/arm64/boot/dts/ddot/ddot/ddot/ddot/ddot/ddot/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-as-p3769-p3737-0000-dsi-tianma-a-dphy.dtb] Error 1
make[1]: *** Waiting for unfinished jobs…
DTC arch/arm64/boot/dts/ddot/ddot/ddot/ddot/ddot/ddot/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dtb
In file included from arch/arm64/boot/dts/…/…/…/…/…/…/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dts:17:0:
arch/arm64/boot/dts/…/…/…/…/…/…/hardware/nvidia/platform/t23x/concord/kernel-dts/cvm/tegra234-p3701-0000.dtsi:19:10: fatal error: t234-common-cvm/tegra234-cvm-p3701.dtsi: No such file or directory
#include <t234-common-cvm/tegra234-cvm-p3701.dtsi>
compilation terminated.
arch/arm64/boot/dts/Makefile:79: recipe for target ‘arch/arm64/boot/dts/ddot/ddot/ddot/ddot/ddot/ddot/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dtb’ failed
make[1]: *** [arch/arm64/boot/dts/ddot/ddot/ddot/ddot/ddot/ddot/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-p3737-0000.dtb] Error 1
DTC arch/arm64/boot/dts/ddot/ddot/ddot/ddot/ddot/ddot/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-as-p3701-0004-p3737-0000.dtb
In file included from arch/arm64/boot/dts/…/…/…/…/…/…/hardware/nvidia/platform/t23x/concord/kernel-dts/tegra234-p3701-0000-as-p3701-0004-p3737-0000.dts:17:0:
arch/arm64/boot/dts/…/…/…/…/…/…/hardware/nvidia/platform/t23x/concord/kernel-dts/cvm/tegra234-p3701-0000.dtsi:19:10: fatal error: t234-common-cvm/tegra234-cvm-p3701.dtsi: No such file or directory
#include <t234-common-cvm/tegra234-cvm-p3701.dtsi>
compilation terminated.

Yes, nvidia clearly didn’t sanity test the public sources that they posted. But, they aren’t the only chipset vendor to have done this.

We don’t know exactly drivers nvidia has tested, what is know working, and known not working. The 5.0 DP release notes are pretty sketchy and don’t get down to the level of kernel config flags.

I think that if you deviate from the 5.0 DP tegra-defconfig, you are on your own. Nvidia would be wise to publish some guidance on how they recommend proceeding in updating customized 4.9 kernel defconfig’s into 5.10 kernel space. As no-longer supported kernel drivers have been left in place (not removed from Kconfig and source) it’s going to be ugly. Best to start with the 5.0 DP tegra-defconfig and then slowly see what other kernel flags you need to tweak. grep is your friend ;-)

The DTC_INCLUDE path fix was pretty straight forward. I’ll leave this exercise to the reader.

1 Like

Yes some of the driver supports have been removed but still they are kept in the source. It is quite confusing and the dtsi missing files have been located in some other directories. Had to manually copy them and modify #include statements. After doing so I was able to build the kernel.
Yes, the documentation they provided does not have proper information and it would have been really helpful if they provided some information on porting from 4.9 to 5.10 for building custom images.

Thank you for hinting “DTC_INCLUDE”.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.