How to modify the device tree of JetPack 6.0?

Hi,

I’m using the custom board for AGX Orin, and I would like to know how to modify the device tree
in JetPack 6.0 BSP, because the way of modify device tree was different from before.

And I ref some comments[Link1][Link2], to modify the device tree can use below method:

1.Decompile the/boot/dtb/kernel_XXX-nv.dtb board, and then assemble back to dtb after the modification.

  1. Device Tree Overlays

But in JetPack 5 modify the device tree was(take porting tpm for example):
$ nano /hardware/nvidia/platform/t23x/concord/kernel-dts/cvb/tegra234-p3737-0000-a04.dtsi (add tpm setting)
image

So my question is : Does JetPack 6 have same way to modify the device tree ? or the only two way is:

  1. Decompile the dtb on the agx orin
  2. Use Device Tree Overlays.

Hi SamM11,

Yes, you can also modify the device tree from the source and recompile kernel image/dtb to apply the change.

Hi @KevinFFF ,
Can you kindly share the place of device tree ? Because I not sure where it is.

The way I see the current place was:(take porting tpm for example)

$ nano /Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public/nv-soc/tegra234-soc-overlay.dtsi

Am I right?

messageImage_1713450113322

Many Thanks!!

Yes, it is the one you can modify the device tree for node spi@3210000.

Hi @KevinFFF ,
So if I modify the device tree like above, and how to recompile kernel image/dtb to apply the change? (or have any document can make me to ref)
The way before(JP5.1.2) was :
set env variable(as a script)

#!/bin/bash
export JETPACK=$PWD
export KERNEL_OUT=$PWD/source/public/kernel_out
export KERNEL_MODULES_OUT=$PWD/source/public/kernel_out/modules

$ cd Linux_for_Tegra/source/public
$ ./nvbuild.sh -o $KERNEL_OUT
$ cd Linux_for_Tegra/
$ sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1

Many Thanks!!

To build and update dtb in JP6.0 DP, please refer to the following instruction.
Kernel Customization — Building the DTBs

Hi @KevinFFF ,
Thank you for reply.
The following error occurred when I execute the make dtbs.log.txt (17.4 KB)

$ cd /Linux_for_Tegra/source
$ export CROSS_COMPILE=/bin/aarch64-buildroot-linux-gnu-
$ export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
$ make dtbs

The error shows like below :

/Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public/nv-soc/tegra234-base-overlay.dtsi:703.2-6 syntax error
FATAL ERROR: Unable to parse input tree

But actually I didn’t modify the tegra234-base-overlay.dtsi file. So what’s the problem here?

Many Thanks!!

Can you share this device tree file for further check?

Hi @KevinFFF ,
Thank you for reply.
Here you are:
tegra234-base-overlay.dtsi.txt (19.8 KB)

Many Thanks!!

I just verify it on my host and dtb can be built successfully as following.

 ================================================================================
 DTBs compiled successfully.
 ================================================================================

It seems your tegra234-base-overlay.dtsi is different from mine.

Can you share the result of the following command on your host?

$ cd <Linux_for_Tegra>/source/hardware/nvidia/t23x/nv-public
$ git branch -r
$ git tag

Hi @KevinFFF ,

The result shows this error when I excute this:

$ git branch -r
fatal: not a git repository (or any of the parent directories): .git

Is it because I didn’t use this way to build kernel source? To Sync the Kernel Sources with Git

What I am using now is To Manually Download and Expand the Kernel Sources

Am I right?

Many Thanks!!

Yes, I used this method to sync the source.

You have to specify the release tag when you run source_sync.sh.
For JP6.0-DP(L4T R36.2), it is jetson_36.2

Hi @KevinFFF ,
Thank you for reply.

below is my output:

Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public$ git branch -r
  origin/HEAD -> origin/master
  origin/l4t/l4t-r36.2
  origin/master
  origin/rel-36
/Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public$ git tag
jetson_36.2
rel-36_eng_2023-10-04
rel-36_eng_2023-11-07
rel-36_eng_2023-12-04
rel-36_eng_2023-12-12
rel-36_eng_2024-01-03
rel-36_eng_2024-01-12
rel-36_eng_2024-01-24
rel-36_eng_2024-02-05
rel-36_eng_2024-02-27
rel-36_eng_2024-03-06
rel-36_eng_2024-03-14
rel-36_eng_2024-04-04

Many Thanks!!

It seems the same result as mine.

Could you try to build kernel image first and then build dtb under <Linux_for_Tegra>/source/?

Hi @KevinFFF ,
Thank you for reply.
According to Kernel Customization to build kernel image and then build dtb under the <Linux_for_Tegra>/source/

Below is my step to build image under the <Linux_for_Tegra>/source/(build_image_log.txt) (208.6 KB)

$ cd <install-path>/Linux_for_Tegra/source
$ export INSTALL_MOD_PATH=<install-path>/Linux_for_Tegra/rootfs/ 
$ sudo -E make install -C kernel
$ cp kernel/kernel-jammy-src/arch/arm64/boot/Image \
  <install-path>/Linux_for_Tegra/kernel/Image

After build image done,then build dtb under the <Linux_for_Tegra>/source/
build_dtb_log.txt (17.5 KB) and the error occurred like before.

$ cd <install-path>/Linux_for_Tegra/source
$ export CROSS_COMPILE=<toolchain-path>/bin/aarch64-buildroot-linux-gnu-
$ export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
$ make dtbs

Many Thanks!!

Hi @SamM11
Maybe check the line 361 of your txt file. There is commented out one bracket openning, after // phy: phy@1 but it looks like closing one is not commented out. Good luck ;)

ethernet@2310000 {
		status = "okay";
		nvidia,mac-addr-idx = <0>;
		nvidia,phy-reset-gpio = <&tegra_main_gpio TEGRA234_MAIN_GPIO(G, 5) 0>;
		phy-mode = "rgmii-id";
		phy-handle = <&phy_for_orin>;
		/delete-node/ fixed-link;

		mdio {
			compatible = "nvidia,eqos-mdio";
			#address-cells = <1>;
			#size-cells = <0>;

			// phy: phy@1 {
			phy_for_orin: ethernet_phy@0{
				// reg = <1>;
				reg = <0>;
				nvidia,phy-rst-pdelay-msec = <224>; /* msec */
				nvidia,phy-rst-duration-usec = <10000>; /* usec */
				// interrupt-parent = <&tegra_main_gpio>;
				// interrupts = <TEGRA234_MAIN_GPIO(G, 4) IRQ_TYPE_LEVEL_LOW>;

				marvell,copper-mode;
				marvell,reg-init = <0x03 0x12 0x7fff 0x880>;
			};
		};
	};
};

Hi @m.puscian @KevinFFF ,
Thank you for reply.
I didn’t noticed that,thank you for reminding me.
But after I delete that you mention. the new error shows
after_delete_bracket_build_dtb_log.txt (17.7 KB)

By the way @m.puscian have you build Kernel Customization successfully on you custom board or devkit on JP6?

Many Thanks!!

ethernet@2310000 {
		status = "okay";
		nvidia,mac-addr-idx = <0>;
		nvidia,phy-reset-gpio = <&gpio TEGRA234_MAIN_GPIO(G, 5) 0>;
		phy-mode = "rgmii-id";
		phy-handle = <&phy_for_orin>;
		/delete-node/ fixed-link;

		mdio {
			compatible = "nvidia,eqos-mdio";
			#address-cells = <1>;
			#size-cells = <0>;

			// phy: phy@1 {
			phy_for_orin: ethernet_phy@0{
				// reg = <1>;
				reg = <0>;
				nvidia,phy-rst-pdelay-msec = <224>; /* msec */
				nvidia,phy-rst-duration-usec = <10000>; /* usec */
				// interrupt-parent = <&tegra_main_gpio>;
				// interrupts = <TEGRA234_MAIN_GPIO(G, 4) IRQ_TYPE_LEVEL_LOW>;

				marvell,copper-mode;
				marvell,reg-init = <0x03 0x12 0x7fff 0x880>;
			};
		};
};

It’s building now. Where is &tegra_main_gpio defined?
And I’m using devkit.

Hi @m.puscian @KevinFFF ,
Thank you for reply.
This way is to enable RGMII on my agx orin, it’s worked for JP5.1.2.
But turn to the new JP version from 5.1.2 to 6, use the same way to modify device tree it doesn’t work.
In JP5.1.2 added above way to modify device tree was in tegra234-soc-eqos.dtsi, and In JP6 was in tegra234-base-overlay.dtsi, am I right?

Many Thanks!!

Yes, we would suggest modifying the overlay dtsi in JP6.