Syntax error when compiling device tree usb-otg modification

Hello,

I have a custom carrier board with microusb port for flashing, and I’m attempting to use it in otg mode. For this, according to Adaptation guide I need to modify the device tree.

I’m using Jetson Orin Nano 8GB, Jetpack 6.0 (rev. 1)

My plan is following:

  1. Decompile current .dtb file into .dts and apply modification
  2. Compile the modified file back into .dtb
  3. Use device tree overlay method to apply the new device tree

I’ve identified tegra234-p3768-0000+p3767-0003-nv.dtb located in /rootfs/boot as the main device tree.

I decompiled it into temp.dts with

sudo dtc tegra234-p3768-0000+p3767-0003-nv.dtb -o temp.dts

Added the modification (starting at line 3706):

			ports {

				usb2-0 {
					status = "okay";
					mode = "otg";
					vbus-supply = <0xe9>;
					usb-role-switch;
					connector {
						compatible = "gpio-usb-b-connector";
						label = "micro-USB";
						type = "micro";
						vbus-gpio = <&gpio TEGRA234_MAIN_GPIO(Z, 1) GPIO_ACTIVE_LOW>;
						id-gpio = <&gpio TEGRA234_MAIN_GPIO(H, 0) GPIO_ACTIVE_HIGH>;
					};
					port {

						endpoint {
							remote-endpoint = <0xea>;
							phandle = <0xf7>;
						};
					};
				};

When I try to compile it back with

sudo dtc temp.dts -o tegra234-p3768-0000+p3767-0003-mod-nv.dtb 

I get:

Error: temp.dts:3717.26-27 syntax error
FATAL ERROR: Unable to parse input tree

which indicates an error on this line:

						vbus-gpio = <&gpio TEGRA234_MAIN_GPIO(Z, 1) GPIO_ACTIVE_LOW>;

Could you please tell me what I’m doing wrong?

Hi xlucny,

Are you using R36.2 or R36.3?
Please share the result of the following command on your board.

$ cat /etc/nv_tegra_release

The macro of TEGRA234_MAIN_GPIO can only be used from the source.
You should download the kernel source and modify the device tree and rebuild the kernel image/dtb.
dtc tool would only handle for the hex value so that you can not specify those macro and use dtc tool to assemble it back to dtb.

R36.3

# R36 (release), REVISION: 3.0, GCID: 36191598, BOARD: generic, EABI: aarch64, DATE: Mon May  6 17:34:21 UTC 2024
# KERNEL_VARIANT: oot
TARGET_USERSPACE_LIB_DIR=nvidia
TARGET_USERSPACE_LIB_DIR_PATH=usr/lib/aarch64-linux-gnu/nvidia

Thank you for the explanation. Can the macro be somehow replaced with raw value, so I can avoid building kernel? (it would be faster)

You can check if another node uses the similar attribute likeTEGRA234_MAIN_GPIO to know what should be specified in your case. Some hex value is generated during flash (e.g. phandle).

We would suggest you rebuilding kernel image/dtb since you may need to do further customization and you might still need to build kernel.

Okay, thank you. I’ll open new topics if any other issues arise.

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