How to define the PIN number for GPIO that is not in the 40PIN?

Dear teachers:
I have been using my self-designed motherboard to develop hardware programs recently, but I
found that GPIO5 is not within the 40PIN sequence. Therefore, when I use the library RPi.GPIO,
I cannot find the pin number. I would like to ask the teacher, how to define the PIN number for
GPIO outside of the 40PIN sequence?

The detailed code is as follows:

I hope the teacher can provide guidance as soon as possible. The project is quite urgent.

Hi 403199668,

What’s the Jetpack version in use?

Do you mean the following pin for GPIO05?
image
If so, please refer to Extending Jetson.GPIO to support gpio pins that are not on the 40 pin header - #3 by KevinFFF for the similar use case to add new GPIO into the list.

Thank you for your guidance, it’s GPO05,I am using ORIN NANO 4GB core board, Jetpack is 5.1.5.

Please refer to
jetson-gpio/lib/python/Jetson/GPIO/gpio_pin_data.py at master · NVIDIA/jetson-gpio · GitHub for the table that you should customize.

Please also share the result of cat /etc/nv_boot_control.conf on your board for further check.

# - Pin number (BOARD mode)
# - Pin number (BCM mode)

Above 2 numbers could be just 2 unused values in the list.
Please also refer to Extending Jetson.GPIO to support gpio pins that are not on the 40 pin header - #5 by KevinFFF as the example.

Hello, after studying the materials you shared, I still have two questions。

1. Where is the PINMUX table located? How can I find GPIO05?

2. Do I need to add a line similar to the following in the gpio_pin_data. py file? What values should be written for the three X’s?

Okay, you are using Orin Nano 4GB module(SKU4).

It can be found with Jetson Orin NX Series and Jetson Orin Nano Series Pinmux from Jetson Download Center.

If you want to add the support to control GPIO05, please modify it as following:

JETSON_ORIN_NX_PIN_DEFS = [
+   (14, 'PCC.02', "tegra234-gpio-aon", 41, 28, 'GPIO05', 'GP08_SPI2_MOSI', None, None, 0x0c302028),
    (144, 'PAC.06', "tegra234-gpio", 7, 4, 'GPIO09', 'GP167', None, None, 0x2448030),

What do 28,PCC.02,tegra234-gpio-aon,14,PCC.02,0x0c302028 mean here? Why did you choose this number?
Because I still have a lot of GPIO to set up, I must learn how to calculate it.

Teacher
Is the BCM code for GPIO05 28?

teacher:
After I made the modifications, the running result is as follows. What’s going on?

Teacher, why don’t you answer the question?

I modified the file “gpio_pin_data.py” (as shown in Figure 1 below) and wrote debugging code (as shown in Figure 2). However, an error like Figure 3 appeared during runtime.
I want to ask the “expert” where I went wrong and how I should make the corrections.

Figure 1:

Figure 2:

Figure 3:

41 and 28 are just 2 unused number in JETSON_ORIN_NX_PIN_DEFS
41 is the number for GPIO.BOARD
28 is the number for GPIO.BCM
PCC.02 is the name from sysfs(i.e. /sys/kernel/debug/gpio)
tegra234-gpio-aon is its gpio controller (i.e. AON GPIO)
14 is the number from gpioinfo, it is line 14 of gpiochip1 [tegra234-gpio-aon]

line  14:     "PCC.02"       unused  output  active-high

0x0c302028 is the PADCTL for this GPIO(i.e. PADCTL_AO_SPI2_MOSI_0 in your case), you can get it from TRM.

Yes, I select 28 as BCM for GPIO05.
If you configure GPIO.setmode(GPIO.BCM) in your application, please just use BCM code for pin.

Please confirm that you’ve run sudo python3 setup.py install after you updated the gpio_pin_data.py.

Thank you for your guidance, but when I followed the “READ ME” installation, the following prompt appeared. May I ask if I missed any steps?

root@lstd:~# sudo pip install Jetson.GPIO
sudo: pip: command not found
root@lstd:~# sudo python3 /home/lstd/Downloads/jetson-gpio/setup.py install
Traceback (most recent call last):
File “/home/lstd/Downloads/jetson-gpio/setup.py”, line 21, in
from setuptools import setup
ModuleNotFoundError: No module named ‘setuptools’
root@lstd:~# sudo python3 setup.py install
python3: can’t open file ‘setup.py’: [Errno 2] No such file or directory

Please run the following commands to setup Jetson.GPIO

$ sudo apt update
$ sudo apt install git python3-pip pip
$ git clone https://github.com/NVIDIA/jetson-gpio.git
$ cd jetson-gpio
$ sudo python3 setup.py install

Done, thank you very much for your guidance. It should be modified first and then installed. I got the logic wrong.

Please always run sudo python3 setup.py install if you have any update under jetson-gpio/lib/.

OK. Thank you for your guidance.

JETSON_ORIN_NX_PIN_DEFS = [
+   (14, 'PCC.02', "tegra234-gpio-aon", 41, 28, 'GPIO05', 'GP08_SPI2_MOSI', None, None, 0x0c302028),
    (144, 'PAC.06', "tegra234-gpio", 7, 4, 'GPIO09', 'GP167', None, None, 0x2448030),

teacher:
Can you tell me how to find the contents of “0x0c302028” and “GP08_SPI2_MOSI”? I cannot find it on Jetson_orin_nX_and_orin_nano_deries_Pinmux_Cnfig_Template-v1.1.xlsm and Jetson Orin Series SoC Technical Reference ManualV1.2p.ddf.