Can not control GPIO on Jetson Orin Nano

Jetson Orin Nano+JetPack6.2.1, I can’t control GPIO, the following is what I did.

Based on the following table, the official Jetson pinmux table, and the gpioinfo command, the

correspondence between GPIOs and PORTs can be determined.

So I tried using the following command to control the GPIO.

~$ sudo gpioinfo 0 | grep -n 144
146:    line 144:     "PAC.06"       unused   input  active-high

~$ sudo gpioset -m wait gpiochip0 144=1
(While it is running)

~$ sudo gpioinfo 0 | grep -n 144
146:    line 144:     "PAC.06"    "gpioset"  output  active-high [used]

~$ sudo cat /sys/kernel/debug/gpio | grep PAC.06
 gpio-492 (PAC.06              |gpioset             ) out hi

But in reality, the pin level don’t change.

It still stay low.

All six of these GPIOs are like this.

So I referred to the following link:

https://forums.developer.nvidia.com/t/orin-nano-gpio-not-working-when-using-gpioset-pg-06-gpio07/337256

So I operated according to the following official document.

https://docs.nvidia.com/jetson/archives/r36.3/DeveloperGuide/HR/JetsonModuleAdaptationAndBringUp/JetsonOrinNxNanoSeries.html#mb1-configuration-changes

All 6 GPIOs are modified like this.

Then I click Generate DT File to generate the following files:

Orin-jetson orin nano&nx pinmux dp-gpio-default.dtsi
Orin-jetson orin nano&nx pinmux dp-padvoltage-default.dtsi
Orin-jetson orin nano&nx pinmux dp-pinmux.dtsi

Then I Copy the padvoltage.dtsi and pinmux.dtsi files to the Linux_for_Tegra/bootloader/generic/BCT/ directory and copy the gpio.dtsi file to the Linux_for_Tegra/bootloader/ directory.

Then I changed the GPIOINT_CONFIG in the ./p3767.conf.common file to the gpio.dtsi that I newly generated above.

Replace the file in PINMUX_CONFIG in ./p3768-0000-p3767-0000-a0.conf with pinmux.dtsi, and replace the file in PMC_CONFIG with padvoltage.dtsi.

So I flash with the fllowing command.

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c tools/kernel_flash/flash_l4t_t234_nvme.xml -p "-c bootloader/generic/cfg/flash_t234_qspi.xml" --showlogs --network usb0 jetson-orin-nano-devkit internal

But I encountered the following error.

copying tbcdtbfile(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/kernel/dtb/tegra234-p3768-0000+p3767-0005-nv.dtb)... done.
copying cfgfile(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/generic/cfg/flash_t234_qspi.xml) to flash.xml... done.
Existing flashapp(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/tegraflash.py) reused.
copying overlay_dtb(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/kernel/dtb/L4TConfiguration.dtbo)... done.
copying overlay_dtb(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/kernel/dtb/tegra234-carveouts.dtbo)... done.
copying overlay_dtb(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/kernel/dtb/tegra-optee.dtbo)... done.
copying overlay_dtb(/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/kernel/dtb/tegra234-p3768-0000+p3767-0000-dynamic.dtbo)... done.
/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/L4TConfiguration_updated.dts: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/L4TConfiguration.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
./tegraflash.py --bl uefi_jetson_minimal_with_dtb.bin --odmdata gbe-uphy-config-8,hsstp-lane-map-3,hsio-uphy-config-0 --overlay_dtb L4TConfiguration.dtbo,tegra234-carveouts.dtbo,tegra-optee.dtbo,tegra234-p3768-0000+p3767-0000-dynamic.dtbo, --bldtb tegra234-p3768-0000+p3767-0005-nv.dtb --applet mb1_t234_prod.bin --cmd "sign" --cfg flash.xml --chip "0x23" --concat_cpubl_bldtb --cpubl uefi_jetson.bin --cpubl_rcm uefi_jetson_minimal.bin --minratchet_config tegra234-mb1-bct-ratchet-p3767-0000.dts --device_config tegra234-mb1-bct-device-p3767-0000.dts --misc_config tegra234-mb1-bct-misc-p3767-0000.dts --pinmux_config Orin-jetson orin nano&nx pinmux dp-pinmux.dtsi --pmic_config tegra234-mb1-bct-pmic-p3767-0000-a02.dts --pmc_config Orin-jetson orin nano&nx pinmux dp-padvoltage-default.dtsi --deviceprod_config tegra234-mb1-bct-cprod-p3767-0000.dts --prod_config tegra234-mb1-bct-prod-p3767-0000.dts --scr_config tegra234-mb2-bct-scr-p3767-0000.dts --wb0sdram_config tegra234-p3767-0001-wb0sdram-l4t.dts --br_cmd_config tegra234-mb1-bct-reset-p3767-0000.dts --uphy tegra234-mb1-bct-uphylane-si.dtsi --dev_params tegra234-br-bct-p3767-0000-l4t.dts,tegra234-br-bct_b-p3767-0000-l4t.dts --mb2bct_cfg tegra234-mb2-bct-misc-p3767-0000.dts --bins "psc_fw pscfw_t234_prod.bin; mts_mce mce_flash_o10_cr_prod.bin; tsec_fw tsec_t234.bin; mb2_applet applet_t234.bin; mb2_bootloader mb2_t234.bin; xusb_fw xusb_t234_prod.bin; pva_fw nvpva_020.fw; dce_fw display-t234-dce.bin; nvdec nvdec_t234_prod.fw; bpmp_fw bpmp_t234-TE950M-A1_prod.bin; bpmp_fw_dtb tegra234-bpmp-3767-0003-3509-a02.dtb; rce_fw camera-rtcpu-t234-rce.img; ape_fw adsp-fw.bin; spe_fw spe_t234.bin; tos tos-optee_t234.img; eks eks_t234.img" --sdram_config tegra234-p3767-0001-sdram-l4t.dts --cust_info custinfo_out.bin --bct_backup --boot_chain A --ramcode 2 
/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/odmsign.func: line 182: nx: command not found
/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/odmsign.func: line 182: nx: command not found
cp: cannot stat 'signed/*': No such file or directory
cp: cannot stat 'signed/flash.xml.tmp': No such file or directory
Using bpmp-dtb concatenated with odmdata in blob for t23x
./tegraflash.py --bl uefi_jetson_minimal_with_dtb_sigheader.bin.encrypt --bct br_bct_BR.bct --bldtb tegra234-p3768-0000+p3767-0005-nv.dtb --applet rcm_2_encrypt.rcm --applet_softfuse rcm_1_encrypt.rcm --cmd "secureflash;reboot"  --cfg secureflash.xml --chip 0x23 --mb1_bct mb1_bct_MB1_sigheader.bct.encrypt --mem_bct mem_rcm_sigheader.bct.encrypt --mb1_cold_boot_bct mb1_cold_boot_bct_MB1_sigheader.bct.encrypt --mb1_bin mb1_t234_prod_aligned_sigheader.bin.encrypt --psc_bl1_bin psc_bl1_t234_prod_aligned_sigheader.bin.encrypt --mem_bct_cold_boot mem_coldboot_sigheader.bct.encrypt  --bins "psc_fw pscfw_t234_prod_sigheader.bin.encrypt; mts_mce mce_flash_o10_cr_prod_sigheader.bin.encrypt; tsec_fw tsec_t234_sigheader.bin.encrypt; mb2_applet applet_t234_sigheader.bin.encrypt; mb2_bootloader mb2_t234_with_mb2_bct_MB2_sigheader.bin.encrypt; xusb_fw xusb_t234_prod_sigheader.bin.encrypt; pva_fw nvpva_020_sigheader.fw.encrypt; dce_fw display-t234-dce_sigheader.bin.encrypt; nvdec nvdec_t234_prod_sigheader.fw.encrypt; bpmp_fw bpmp_t234-TE950M-A1_prod_sigheader.bin.encrypt; bpmp_fw_dtb tegra234-bpmp-3767-0003-3509-a02_with_odm_sigheader.dtb.encrypt; rce_fw camera-rtcpu-t234-rce_sigheader.img.encrypt; ape_fw adsp-fw_sigheader.bin.encrypt; spe_fw spe_t234_sigheader.bin.encrypt; tos tos-optee_t234_sigheader.img.encrypt; eks eks_t234_sigheader.img.encrypt"    --bct_backup 
saving flash command in flashcmd.txt

*** no-flash flag enabled. Exiting now... *** 

User can run above saved command in factory environment without 
providing pkc and sbk keys to flash a device

Example:

    $ cd bootloader 
    $ sudo bash ./flashcmd.txt

Welcome to Tegra Flash
version 1.0.0
Type ? or help for help and q or quit to exit
Use ! to execute system commands
 
[   0.0117 ] tegrasign_v3.py --key None --getmode mode.txt
[   0.0118 ] Assuming zero filled SBK key
[   0.0114 ] Parsing partition layout
[   0.0117 ] tegraparser_v2 --pt flash.xml.tmp
Traceback (most recent call last):
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/tegraflash_impl_t234.py", line 1568, in tegraflash_update_bpmp_dtb
    if bpmp_dtb == None and bpmp_dtb_in_layout == None:
UnboundLocalError: local variable 'bpmp_dtb' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/./tegraflash.py", line 1462, in <module>
    tegraflash_run_commands()
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/./tegraflash.py", line 1279, in tegraflash_run_commands
    interpreter.onecmd(command)
  File "/usr/lib/python3.10/cmd.py", line 217, in onecmd
    return func(arg)
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/./tegraflash.py", line 771, in do_sign
    self.chip_inst.tegraflash_sign(exports)
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/tegraflash_impl_t234.py", line 3078, in tegraflash_sign
    self.tegraflash_parse_partitionlayout()
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/tegraflash_impl_t234.py", line 502, in tegraflash_parse_partitionlayout
    self.tegraflash_update_bpmp_dtb()
  File "/home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/tegraflash_impl_t234.py", line 1635, in tegraflash_update_bpmp_dtb
    raise tegraflash_exception('Unexpected error in updating: ' + bpmp_dtb + ' ' + str(e))
UnboundLocalError: local variable 'bpmp_dtb' referenced before assignment
Error: /home/evoc/aib1100/r3644/nano/Linux_for_Tegra/bootloader/signed/flash.idx is not found
Error: failed to relocate images to /home/evoc/aib1100/r3644/nano/Linux_for_Tegra/tools/kernel_flash/images
Cleaning up...

What should I do, what is the right thing to do?

Hope to get an answer.

Thank you!!!

Hi ZXZhang,

It is not the expected operation to me.

gpio.dtsi has been inlcuded in pinmux.dtsi so it does not need to be specified in board config.
GPIOINT_CONFIG is used for gpio-interrupt configuration.

Do you modify any line relating to bpmp-dtb?

To control GPIO with Jetpack 6.x, please also apply the patch from the following thread.
40hdr - SPI1 gpio padctl register bit[10] effect by gpiod tools in JP6 - #20 by KevinFFF
Or you can use Jetpack 6.2.2(r36.5) which should include that patch.

I don’t know if this is the correct solution but I simply ran /opt/nvidia/jetson-io/jetson-io.py and selected “Configure the Jetson 40pin Header”. I then selected “Configure header pins manually”. The unused header pins are then displayed. I selected pin 7 as gpio and finally the option to save pin configuration and reboot.

After the re-boot I ran the following script and the led blinked.

Script:

import Jetson.GPIO as GPIO
import time

led_pin = 7

GPIO.setmode(GPIO.BOARD)
GPIO.setup(led_pin,GPIO.OUT,initial=GPIO.LOW)

try:
while True:
GPIO.output(led_pin, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(led_pin, GPIO.LOW)
time.sleep(0.5)
except KeyboardInterrupt:
print(“exiting gracefully”)
GPIO.output(led_pin, GPIO.LOW)
GPIO.cleanup()

OK, I tried to apply the patch but it didn’t work.

~$ touch gpio_fix.patch
~$ cd Linux_Tegra/source/kernel/kernel-jammy-src
~$ patch -p1 < ../gpio_fix.patch
patching file drivers/pinctrl/tegra/pinctrl-tegra.c
patching file drivers/pinctrl/tegra/pinctrl-tegra.h

Then I compiled the kernel and flashed it to the Nano.

gpioset --mode=wait `gpiofind "PG.06"`=1

At the same time, I ran the following command:

sudo cat /sys/kernel/debug/gpio | grep PG

The pin still stays low.

What’s the problem?

Like this?

But it didn’t work.

I measured the voltage with a multimeter and it is still low.

In that screenshot pin-7 is shown as aud (audio) you want it set to GPIO

How? I press enter but it only Added a * .

Removing the * in front that mains set it to GPIO ?

Please do not use Jetson-IO tool if you want to use the pin as GPIO and control it.

Have you confirmed that you’ve applied this patch correctly?

Which pin would you like to control? PAC.06 or PG.06?

I believe I have applied the patch correctly.

I’d like to try controlling all of them, but let’s start with PG.06.

Could you please tell me how to proceed?

If you have applied the patch correctly, please configure its pinmux as GPIO/Output/Drive 0 in pinmux spreadsheet before you run gpioset to control it.