How to check the GPIO pinmux of Orin NX and set the GPIO pinmux?

Hi:
Here is my device version:

Software part of jetson-stats 4.3.2 - (c) 2024, Raffaello Bonghi
Model: NVIDIA Orin NX Developer Kit - Jetpack 5.1.3 [L4T 35.5.0]
NV Power Mode[2]: 15W
Serial Number: [XXX Show with: jetson_release -s XXX]
Hardware:
 - P-Number: p3767-0001
 - Module: NVIDIA Jetson Orin NX (8GB ram)
Platform:
 - Distribution: Ubuntu 20.04 focal
 - Release: 5.10.192-tegra
jtop:
 - Version: 4.3.2
sh: 0: getcwd() failed: Input/output error
 - Service: Active
Libraries:
 - CUDA: 11.4.315
 - cuDNN: 8.6.0.166
 - TensorRT: 8.5.2.2
 - VPI: 2.4.8
 - Vulkan: 1.3.204
 - OpenCV: 4.5.4 - with CUDA: NO

We designed our own hardware,now I need to set the used pins to GPIO, Download and to check Jetson_Orin_NX_and_Orin_Nano_series_Pinmux_Config_Template.xlsm,I choose to set SPI0_CS1/SPI1_CS0/SPI1_CS1 to gpio:


Then I checked gpio config file :tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi:

gpio@2200000 {
		gpio-init-names = "default";
		gpio-init-0 = <&gpio_main_default>;

		gpio_main_default: default {
			gpio-input = <
				TEGRA234_MAIN_GPIO(B, 0)
				TEGRA234_MAIN_GPIO(Y, 0)
				TEGRA234_MAIN_GPIO(Y, 1)
				TEGRA234_MAIN_GPIO(Y, 2)
				TEGRA234_MAIN_GPIO(Y, 3)
				TEGRA234_MAIN_GPIO(Y, 4)
				TEGRA234_MAIN_GPIO(Z, 1)
				TEGRA234_MAIN_GPIO(Z, 3)
				TEGRA234_MAIN_GPIO(Z, 4)
				TEGRA234_MAIN_GPIO(Z, 5)
				TEGRA234_MAIN_GPIO(Z, 6)
				TEGRA234_MAIN_GPIO(Z, 7)
				TEGRA234_MAIN_GPIO(P, 6)
				TEGRA234_MAIN_GPIO(Q, 5)
				TEGRA234_MAIN_GPIO(Q, 6)
				TEGRA234_MAIN_GPIO(R, 4)
				TEGRA234_MAIN_GPIO(R, 5)
				TEGRA234_MAIN_GPIO(M, 0)
				TEGRA234_MAIN_GPIO(N, 1)
				TEGRA234_MAIN_GPIO(G, 0)
				TEGRA234_MAIN_GPIO(G, 6)
				TEGRA234_MAIN_GPIO(G, 7)
				TEGRA234_MAIN_GPIO(H, 0)
				TEGRA234_MAIN_GPIO(H, 7)
				TEGRA234_MAIN_GPIO(I, 0)
				TEGRA234_MAIN_GPIO(I, 1)
				TEGRA234_MAIN_GPIO(I, 2)
				TEGRA234_MAIN_GPIO(AC, 6)
				TEGRA234_MAIN_GPIO(L, 2)
				>;
			gpio-output-low = <
				TEGRA234_MAIN_GPIO(H, 6)
				TEGRA234_MAIN_GPIO(I, 5)
				TEGRA234_MAIN_GPIO(AC, 0)
				TEGRA234_MAIN_GPIO(K, 4)
				TEGRA234_MAIN_GPIO(K, 5)
				>;
			gpio-output-high = <
				TEGRA234_MAIN_GPIO(Q, 3)
				TEGRA234_MAIN_GPIO(A, 0)
				>;
		};
	};

I don’t know which configuration in the config file corresponds to GPIO3_PY.03. If I set GPIO3_PY.03 as GPIO output and the default low level, how should I configure it?
And how can I check the pin reuse configuration on the device? Is there any command to confirm the configuration of the pin taking effect?
Looking forward to your reply!

Hi jack.yan,

Please just configure it as GPIO3_PY.03/Output/Drive 0 in pinmux spreadsheet.

Please use sysfs command to export the pin and check its state.

$ sudo su
# cat /sys/kernel/debug/gpio | grep PY.03
# echo xxx > /sys/class/gpio/export
# cd /sys/class/gpio/PY.03
# cat direction
# cat value

Or you can use gpiod to check:


$ sudo gpioinfo|grep "PY.03"

Dear KevinFFF:
Thank you very much for your reply. I want to quickly verify whether these pins can be reused as GPIO. Now I logging in to the Ubuntu desktop. Is there any way to quickly set them in the command line for verification?

I Modified Jetson_Orin_NX_and_Orin_Nano_series_Pinmux_Config_Template.xlsm and generate DT file again, and then compare with default dtsi file ,The differences are as follows:


For the generated file, I will change the file name to tegra234-mb1-bct-gpio-p3767-hdmi-a03.dtsi, replace it in the Linux_for_Tegra/bootloader directory, and then burn all partition by l4t_initrd_flash.sh? Can I directly copy this file to the device for replacement, and restart the device to take effect?

If I want to set GPIO to interrupt, do I only need to set GPIO to GPIO3_PY.03/Input/int PU(int PD)?

It is correct steps to apply the change.

Sorry that pinmux/gpio dtsi are loaded in early boot(MB1) so that you have to reflash the board to apply the change.

Yes, and also add it in device tree to be loaded by your driver to handle the interrupt.

Hi,KevinFFF:
Thank you very much for your reply.you said “and also add it in device tree to be loaded by your driver to handle the interrupt.”,Aren’t the generated gpio and pinmux files device tree files? Which file still needs to be modified?

The current steps are to configure the pinmux register for the pin you want to use.
It could be configured as an Input pin if you’ve configured it correctly.

You’ve mentioned that you want to use it as interrupt.
Normally, it could be specified in device tree so that the kernel driver can handle the interrupt coming from this pin. I’m not sure your exact use case for this pin to be interrupt pin.