GPIO pins issue

Hi all!

We have:
Module Nvidia Jetson Orin NX 16 Gb,
Connect Tech Boson Carrier Board for NVIDIA® Jetson Orin™ NX (https://connecttech.com/product/boson-for-framos-carrier-board-for-nvidia-jetson-orin-nx/),
BSP from Connect Tech JetPack 5.1.1 – L4T r35.3.1 - Orin NX L4T r35.3.1 BSP.

I installed the relevant software components using the sdkmanager package manager. I downloaded the sources to the sources folder. I copied Orin NX L4T r35.3.1 BSP to nvidia_sdk/JetPack_5.1.1_Linux_JETSON_ORIN_NX_TARGETS/Linux_for_Tegra/, unpacked it and did it according to the instructions.

The task is this: the changed GPIOs must be flashed onto the Boson Carrier Board along with the Orin NX 16 Gb and toggled.
Required gpio’s - GPIO0 and GPIO4. There is program code below that will toggle values.

We were given files with modified GPIOs (gpio.dtsi, padvoltage.dtsi, pinmux.dtsi). Generated using Jetson_Orin_NX_series_and_Orin_Nano_series_Pinmux_Config_Template.xlsm. According to instructions
Jetson Orin NX Series — Jetson Linux Developer Guide documentation ,
copy the padvoltage.dtsi and pinmux.dtsi files to the <l4t_top>/bootloader/t186ref/BCT/ directory and copy the gpio.dtsi file to the <l4t_top>/bootloader/ directory. From Linux_for_Tegra/CTI-L4T/conf/cti/orin-nx/boson copied base.conf to Linux_for_Tegra/, Linux_for_Tegra/CTI-L4T/conf copied cti-orin-nx.conf.common to /Linux_for_Tegra/

I changed file base.conf:

source "${LDK_DIR}/cti-orin-nx.conf.common";

DTB_FILE="tegra234-orin-nx-cti-NGX007.dtb";
PINMUX_CONFIG="**pinmux.dtsi**"; <<

DEFAULT_EMC_FUSE="0";
PMC_CONFIG="**padvoltage.dtsi**"; <<
BPFDTB_FILE="tegra234-bpmp-3767-0000-a02-3509-a02.dtb";
TBCDTB_FILE="${DTB_FILE}";
EMMC_CFG="flash_t234_qspi_sd.xml";
MB2_BCT="tegra234-cti-orin-nx-mb2-bct-misc.dts";

ext_target_board=cti-orin-nx-ngx007-00;

Saved file and run in terminal:

$ sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 \
  -c tools/kernel_flash/flash_l4t_external.xml -p "-c bootloader/t186ref/cfg/flash_t234_qspi.xml" \
  --showlogs --network usb0 base internal

The firmware was successful, now we had to check the GPIO - toggle gpio’s. Perhaps I did it right?

Further,
GPIO0 - SODIMM pin - 87 gpio number 479 PZ.01
GPIO4 - SODIMM pin - 127 gpio number 329 PCC.01

In terminal I run commands:

root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# echo PZ.01 > /sys/class/gpio/export
bash: echo: write error: Device or resource busy
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# ls -l /sys/class/gpio/export
--w------- 1 root root 4096 Dec 28 09:20 /sys/class/gpio/export
root@demon-desktop:/home/demon# ls -l /sys/class/gpio/
export       gpiochip300/ gpiochip316/ gpiochip348/ unexport
root@demon-desktop:/home/demon# ls -l /sys/class/gpio/
total 0
--w------- 1 root root 4096 Dec 28 09:20 export
lrwxrwxrwx 1 root root    0 Sep  8  2022 gpiochip300 -> ../../devices/platform/c250000.i2c/i2c-7/7-0074/gpio/gpiochip300
lrwxrwxrwx 1 root root    0 Sep  8  2022 gpiochip316 -> ../../devices/platform/c2f0000.gpio/gpio/gpiochip316
lrwxrwxrwx 1 root root    0 Sep  8  2022 gpiochip348 -> ../../devices/platform/2200000.gpio/gpio/gpiochip348
--w------- 1 root root 4096 Sep  8  2022 unexport
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# echo PCC.01 > /sys/class/gpio/export
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# ls -l /sys/class/gpio/
export       gpiochip300/ gpiochip316/ gpiochip348/ PCC.01/      unexport
root@demon-desktop:/home/demon# ls -l /sys/class/gpio/PCC.01/
active_low  device/     direction   edge        power/      subsystem/  uevent      value
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# echo out > /sys/class/gpio/
export       gpiochip300/ gpiochip316/ gpiochip348/ PCC.01/      unexport

root@demon-desktop:/home/demon# echo out > /sys/class/gpio/PCC.01/direction

I change the values ​​to see something on the oscilloscope screen

root@demon-desktop:/home/demon# echo 1 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 0 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# echo 1 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 0 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# echo 0 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 1 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon#
root@demon-desktop:/home/demon# echo 1 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 0 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 1 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 0 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 1 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon# echo 0 > /sys/class/gpio/PCC.01/value
root@demon-desktop:/home/demon#

The logical level does not change on the oscilloscope screen

root@demon-desktop:/home/demon# ls -l /sys/class/gpio/
export       gpiochip300/ gpiochip316/ gpiochip348/ PCC.01/      unexport
root@demon-desktop:/home/demon#

root@demon-desktop:/home/demon/Projects# echo PZ.01 > /sys/class/gpio/export
bash: echo: write error: Device or resource busy
root@demon-desktop:/home/demon/Projects#

root@demon-desktop:/home/demon#

There is a small example of a program that switches logic level values. The program does not output anything to the terminal. An oscilloscope is used to check the functionality of the logic level.

Summary

include <stdio.h>
include <stdlib.h>
include <stdint.h>
include <unistd.h>
include <sys/fcntl.h>
include <sys/mman.h>

//Values ​​taken from TRM for Orin NX, pages: 6584, 6587
//define GPIO_392 0x02212420 //GPIO0 config
//define DAP1_SCLK 0x0243d0b0 //GPIO0 pinmux padctl_a13

define GPIO_392 0x0c2f1220 //GPIO4 config
define DAP1_SCLK 0x0c302050 //GPIO4 pinmux padctl_a14

define GPIO_ENABLE_CONFIG 0x00
define GPIO_OUTPUT_CONTROL 0x0c
define GPIO_OUTPUT_VALUE 0x10

int main(void) {
int fd = open(“/dev/mem”, O_RDWR | O_SYNC);
if (fd < 0) {
perror(“/dev/mem”);
fprintf(stderr, “Please run this program as root (for example with sudo)\n”);
exit(1);
}

uint32_t pagesize = getpagesize();
uint32_t pagemask = pagesize - 1;

void *gpio_address = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (GPIO_392 & ~pagemask));
void *pad_ctl_address = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (DAP1_SCLK & ~pagemask));

if (gpio_address == NULL || pad_ctl_address == NULL) {
    perror("mmap()");
    exit(1);
}

volatile char *gpio_base = ((char *)gpio_address + (GPIO_392 & pagemask));
volatile char *pad_ctl = ((char *)pad_ctl_address + (DAP1_SCLK & pagemask));

*pad_ctl = 0x00000000; // Select GPIO

*(gpio_base + GPIO_OUTPUT_CONTROL) = 0x00000000; // Driven
*(gpio_base + GPIO_ENABLE_CONFIG) = 0x00000003; // GPIO Enable, Out

uint32_t val = 0x00000001;
volatile char *output_value = gpio_base + GPIO_OUTPUT_VALUE;

for(int i=0; i<10000; i++) {
    usleep(100000);
    val = val ^ 0x00000001;
    *output_value = val;
}

*output_value = 0x00000000;

munmap(gpio_address, pagesize);
munmap(pad_ctl_address, pagesize);
close(fd);

return 0 ;

}

We checked it with an oscilloscope - no toggled gpio’s. How to fix it?

The links below didn’t help

Thank you for your help.

I don’t know why you write like this. Why you don’t use the full file name?
Are you sure these files are really flashed into the device?

Here is the content of the file base.conf:

source "${LDK_DIR}/cti-orin-nx.conf.common";

DTB_FILE="tegra234-orin-nx-cti-NGX007.dtb";
#PINMUX_CONFIG="tegra234-cti-orin-nx-mb1-bct-pinmux.dtsi";
PINMUX_CONFIG="pinmux.dtsi";

DEFAULT_EMC_FUSE="0";
#PMC_CONFIG="tegra234-mb1-bct-padvoltage-p3767-hdmi-a03.dtsi";
PMC_CONFIG="padvoltage.dtsi";
BPFDTB_FILE="tegra234-bpmp-3767-0000-a02-3509-a02.dtb";
TBCDTB_FILE="${DTB_FILE}";
EMMC_CFG="flash_t234_qspi_sd.xml";
MB2_BCT="tegra234-cti-orin-nx-mb2-bct-misc.dts";

ext_target_board=cti-orin-nx-ngx007-00;

Are you sure these files are really flashed into the device?

At least there were no errors

Check the flashing log and see whether this file name appears in the log.

I decided to check again and an error occurs, although there was no error before. How to fix it?

log_error.txt (16.2 KB)

Try modifying pins one-by-one, and see changes in what pins cause the error.

Rechecked it. Forgot to change it in the file pinmux.dtsi header file to ./gpio.dtsi.

Contents of my files:
gpio.dtsi

Summary

/*This dtsi file was generated by jetson_orin_nx_series_+hdmi a03.xlsm Revision: 1.01 */

include “tegra234-gpio.h”

/ {
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, 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(Z, 1)
			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)
			>;
	};
};
gpio@c2f0000 {
	gpio-init-names = "default";
	gpio-init-0 = <&gpio_aon_default>;

	gpio_aon_default: default {
		gpio-input = <
			TEGRA234_AON_GPIO(EE, 2)
			TEGRA234_AON_GPIO(EE, 4)
			>;
		gpio-output-low = <
			TEGRA234_AON_GPIO(CC, 0)
			TEGRA234_AON_GPIO(CC, 1)
			TEGRA234_AON_GPIO(CC, 2)
			TEGRA234_AON_GPIO(CC, 3)
			TEGRA234_AON_GPIO(AA, 4)
			>;
		gpio-output-high = <
			TEGRA234_AON_GPIO(AA, 5)
			TEGRA234_AON_GPIO(BB, 3)
			>;
	};
};
gpio@9250000 {
	gpio-init-names = "default";
	gpio-init-0 = <&gpio_fsi_default>;

	gpio_fsi_default: default {
		gpio-input = <
			>;
		gpio-output-low = <
			>;
		gpio-output-high = <
			>;
	};
};

};

pinmux.txt (65.8 KB)

I probably reflashed it successfully, but the errors confused me:
log.txt (225.1 KB)

[   2.4598 ] MB1-BCT version: 0.10
[   2.4599 ] ERROR: carveout /misc/carveout/aux_info@CARVEOUT_UNUSED5/ is not supported
[   2.4603 ] ERROR: carveout /misc/carveout/aux_info@CARVEOUT_UNUSED5/ is not supported
[   2.4605 ] ERROR: carveout /misc/carveout/aux_info@CARVEOUT_UNUSED5/ is not supported
[   2.4607 ] ERROR: carveout /misc/carveout/aux_info@CARVEOUT_MCE_COVERAGE/ is not supported
[   2.4609 ] ERROR: carveout /misc/carveout/aux_info@CARVEOUT_MCE_COVERAGE/ is not supported
[   2.4611 ] ERROR: carveout /misc/carveout/aux_info@CARVEOUT_MCE_COVERAGE/ is not supported
[   2.4613 ] ERROR: /misc/tsc_controls/tsc_locking_config is not supported
[   2.4615 ] ERROR: /misc/tsc_controls/tsc_locking_diff_configuration is not supported
[   2.4617 ] ERROR: /misc/tsc_controls/tsc_locking_ref_frequency_configuration is not supported
[   2.4620 ] ERROR: /misc/tsc_controls/tsc_locking_control is not supported
[   2.4622 ] ERROR: /misc/tsc_controls/tsc_locking_adjust_configuration is not supported
[   2.4625 ] ERROR: /misc/tsc_controls/tsc_locking_fast_adjust_configuration is not supported
[   2.4628 ] ERROR: /misc/tsc_controls/tsc_locking_adjust_delta_control is not supported
[   2.4631 ] ERROR: /misc/tsc_controls/tsc_capture_control_ptx is not supported
[   2.4633 ] ERROR: /misc/tsc_controls/tsc_capture_config_ptx is not supported
[   2.4635 ] ERROR: /misc/tsc_controls/tsc_stscrsr is not supported
[   2.4636 ] ERROR: /misc/tsc_controls/tsc_locking_adjust_num_control is not supported

In the source code in the first post I added output to the terminal:

 for(int i=0; i<10000; i++) {
        usleep(100000);
        val = val ^ 0x00000001;
        *output_value = val;
        
        printf("value = %02X\n", *output_value);
    }

For GPIO00 I got this output:

...
value = 00
value = 01
value = 00
value = 01
value = 00
value = 01
value = 00
...

For GPIO04 I got this output:

...
value = FF
value = FF
value = FF
value = FF
value = FF
value = FF
...

In terminal I’m checking:

demon@demon-desktop:~/Projects$ sudo cat /sys/kernel/debug/gpio | grep PZ.01
 gpio-479 (PZ.01               |vbus                ) in  lo IRQ 
demon@demon-desktop:~/Projects$ 
demon@demon-desktop:~/Projects$ sudo cat /sys/kernel/debug/gpio | grep PCC.01
 gpio-329 (PCC.01              )
demon@demon-desktop:~/Projects$ 

According to the modified gpio.dtsi file, GPIO00 and GPIO04 should be on gpio-output-low out. The output in the terminal shows that this is not the case. What else needs to be done to ensure that GPIO00 and GPIO04 are in out?

Get another module or carrier board for cross validation.

I checked it on the second set. Same module and carrier board. The result of the flashing with new GPIOs is the same.

I decided to do this:
in the files gpio.dtsi and pinmux.dtsi changed what is in the original files: tegra234-cti-orin-nx-mb1-bct-gpio.dtsi and tegra234-cti-orin-nx-mb1-bct-pinmux.dtsi with the exception GPIO04 and renamed to original files.

In the original GPIO00 it was like this:

usb_vbus_en0_pz1 {
				nvidia,pins = "usb_vbus_en0_pz1";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

replaced by

usb_vbus_en0_pz1 {
				nvidia,pins = "usb_vbus_en0_pz1";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_NONE>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

GPIO04 looks like this:

			spi2_miso_pcc1 {
				nvidia,pins = "spi2_miso_pcc1";
				nvidia,function = "rsvd1";
				nvidia,pull = <TEGRA_PIN_PULL_NONE>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
			};

After reflashing I get this result:

alex@alex-desktop:~/Projects$ sudo cat /sys/kernel/debug/gpio | grep PZ.01
 gpio-479 (PZ.01               |vbus                ) in  lo IRQ 
alex@alex-desktop:~/Projects$ 
alex@alex-desktop:~/Projects$ 
alex@alex-desktop:~/Projects$ sudo cat /sys/kernel/debug/gpio | grep PCC.01
 gpio-329 (PCC.01              )
alex@alex-desktop:~/Projects$ 

In PZ.01 nvidia,enable-input = <TEGRA_PIN_DISABLE>; In the terminal we see that this is not so. How to fix it?

Can you please get a DevKit for test?
We don’t have this carrier board so really nothing we can help.

Anyway, you also need to modify the gpio file, not only pinmux.

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