See my system and all other configuration.
I wanted to ask How can I map my GPIO.
My code;
import Jetson.GPIO as GPIO
import time
INA = 33
IN1 = 35
IN2 = 36
GPIO.setmode(GPIO.BOARD)
GPIO.setup([INA, IN1, IN2], GPIO.OUT)
try:
# Move Motor A forward
GPIO.output(INA, GPIO.HIGH)
GPIO.output(IN1, GPIO.HIGH)
GPIO.output(IN2, GPIO.LOW)
print(“Motor A moving forward.”)
time.sleep(2)
# Move Motor A backward
GPIO.output(INA, GPIO.LOW)
GPIO.output(IN1, GPIO.LOW)
GPIO.output(IN2, GPIO.HIGH)
print("Motor A moving backward.")
time.sleep(2)
finally:
# Clean up GPIO settings
GPIO.cleanup()
print(“GPIO cleaned up.”)
After running it when I check my multimeter I can see no output current is coming.
Kindly let me know about all the relevant info about GPIO based on my model and jetpack.
So what GPIO pins are you going to use here? I read the whole post but still don’t know which one you are trying to use.
Pin 33 for PWM(l298n motor driver), Pin 35, Pin 36
Did you already configure the pinmux of those 3 pins before using it?
Let me tell you what I did so far;
I followed GitHub - jetsonhacks/jetson-orin-gpio-patch: Addressing GPIO issue in JetPack 6.2 to patch the pinctrl-sfsel and then I Recompile and install the modified kernel by following GitHub - jetsonhacks/jetson-orin-kernel-builder: Build the Linux kernel and modules on board the Jetson AGX Orin, Orin Nano or Orin NX .
Now I hope I should get all GPIO pin work but see the below output;
sourav@MTP-SOURAV:~$ gpioinfo
gpiochip0 - 164 lines:
line 0: "PA.00" "regulator-vdd-3v3-sd" output active-high [used]
line 1: "PA.01" unused input active-high
line 2: "PA.02" unused input active-high
line 3: "PA.03" unused input active-high
line 4: "PA.04" unused input active-high
line 5: "PA.05" unused input active-high
line 6: "PA.06" unused input active-high
line 7: "PA.07" unused input active-high
line 8: "PB.00" unused input active-high
line 9: "PC.00" unused input active-high
line 10: "PC.01" unused input active-high
line 11: "PC.02" unused input active-high
line 12: "PC.03" unused input active-high
line 13: "PC.04" unused input active-high
line 14: "PC.05" unused input active-high
line 15: "PC.06" unused input active-high
line 16: "PC.07" unused input active-high
line 17: "PD.00" unused input active-high
line 18: "PD.01" unused input active-high
line 19: "PD.02" unused input active-high
line 20: "PD.03" unused input active-high
line 21: "PE.00" unused input active-high
line 22: "PE.01" unused input active-high
line 23: "PE.02" unused input active-high
line 24: "PE.03" unused input active-high
line 25: "PE.04" unused input active-high
line 26: "PE.05" unused input active-high
line 27: "PE.06" unused input active-high
line 28: "PE.07" unused input active-high
line 29: "PF.00" unused input active-high
line 30: "PF.01" unused input active-high
line 31: "PF.02" unused input active-high
line 32: "PF.03" unused input active-high
line 33: "PF.04" unused input active-high
line 34: "PF.05" unused input active-high
line 35: "PG.00" "Force Recovery" input active-low [used]
line 36: "PG.01" unused input active-high
line 37: "PG.02" unused input active-high
line 38: "PG.03" unused input active-high
line 39: "PG.04" unused input active-high
line 40: "PG.05" unused input active-high
line 41: "PG.06" unused input active-high
line 42: "PG.07" unused input active-high
line 43: "PH.00" unused input active-high
line 44: "PH.01" unused input active-high
line 45: "PH.02" unused input active-high
line 46: "PH.03" unused input active-high
line 47: "PH.04" unused input active-high
line 48: "PH.05" unused input active-high
line 49: "PH.06" unused output active-high
line 50: "PH.07" unused input active-high
line 51: "PI.00" unused input active-high
line 52: "PI.01" unused input active-high
line 53: "PI.02" unused input active-high
line 54: "PI.03" unused input active-high
line 55: "PI.04" unused input active-high
line 56: "PI.05" kernel input active-high [used]
line 57: "PI.06" unused input active-high
line 58: "PJ.00" unused input active-high
line 59: "PJ.01" unused input active-high
line 60: "PJ.02" unused input active-high
line 61: "PJ.03" unused input active-high
line 62: "PJ.04" unused input active-high
line 63: "PJ.05" unused input active-high
line 64: "PK.00" unused input active-high
line 65: "PK.01" unused input active-high
line 66: "PK.02" unused input active-high
line 67: "PK.03" unused input active-high
line 68: "PK.04" unused output active-high
line 69: "PK.05" unused output active-high
line 70: "PK.06" unused input active-high
line 71: "PK.07" unused input active-high
line 72: "PL.00" unused input active-high
line 73: "PL.01" unused input active-high
line 74: "PL.02" unused input active-high
line 75: "PL.03" unused input active-high
line 76: "PM.00" kernel input active-high [used]
line 77: "PM.01" unused input active-high
line 78: "PM.02" unused input active-high
line 79: "PM.03" unused input active-high
line 80: "PM.04" unused input active-high
line 81: "PM.05" unused input active-high
line 82: "PM.06" unused input active-high
line 83: "PM.07" unused input active-high
line 84: "PN.00" unused input active-high
line 85: "PN.01" unused input active-high
line 86: "PN.02" unused input active-high
line 87: "PN.03" unused input active-high
line 88: "PN.04" unused input active-high
line 89: "PN.05" unused input active-high
line 90: "PN.06" unused input active-high
line 91: "PN.07" unused input active-high
line 92: "PP.00" unused input active-high
line 93: "PP.01" unused input active-high
line 94: "PP.02" unused input active-high
line 95: "PP.03" unused input active-high
line 96: "PP.04" unused input active-high
line 97: "PP.05" unused input active-high
line 98: "PP.06" unused input active-high
line 99: "PP.07" unused input active-high
line 100: "PQ.00" unused input active-high
line 101: "PQ.01" unused input active-high
line 102: "PQ.02" unused input active-high
line 103: "PQ.03" unused output active-high
line 104: "PQ.04" unused input active-high
line 105: "PQ.05" unused input active-high
line 106: "PQ.06" unused input active-high
line 107: "PQ.07" unused input active-high
line 108: "PR.00" unused input active-high
line 109: "PR.01" unused input active-high
line 110: "PR.02" unused input active-high
line 111: "PR.03" unused input active-high
line 112: "PR.04" unused input active-high
line 113: "PR.05" unused input active-high
line 114: "PX.00" kernel input active-high [used]
line 115: "PX.01" kernel input active-high [used]
line 116: "PX.02" unused input active-high
line 117: "PX.03" unused input active-high
line 118: "PX.04" unused input active-high
line 119: "PX.05" unused input active-high
line 120: "PX.06" unused input active-high
line 121: "PX.07" unused input active-high
line 122: "PY.00" unused input active-high
line 123: "PY.01" unused input active-high
line 124: "PY.02" unused input active-high
line 125: "PY.03" unused input active-high
line 126: "PY.04" unused input active-high
line 127: "PY.05" unused input active-high
line 128: "PY.06" unused input active-high
line 129: "PY.07" unused input active-high
line 130: "PZ.00" unused input active-high
line 131: "PZ.01" "interrupt" input active-high [used]
line 132: "PZ.02" unused input active-high
line 133: "PZ.03" unused input active-high
line 134: "PZ.04" unused input active-high
line 135: "PZ.05" unused input active-high
line 136: "PZ.06" unused input active-high
line 137: "PZ.07" unused input active-high
line 138: "PAC.00" unused output active-high
line 139: "PAC.01" unused input active-high
line 140: "PAC.02" unused input active-high
line 141: "PAC.03" unused input active-high
line 142: "PAC.04" unused input active-high
line 143: "PAC.05" unused input active-high
line 144: "PAC.06" unused input active-high
line 145: "PAC.07" unused input active-high
line 146: "PAD.00" unused input active-high
line 147: "PAD.01" unused input active-high
line 148: "PAD.02" unused input active-high
line 149: "PAD.03" unused input active-high
line 150: "PAE.00" unused input active-high
line 151: "PAE.01" unused input active-high
line 152: "PAF.00" unused input active-high
line 153: "PAF.01" unused input active-high
line 154: "PAF.02" unused input active-high
line 155: "PAF.03" unused input active-high
line 156: "PAG.00" unused input active-high
line 157: "PAG.01" unused input active-high
line 158: "PAG.02" unused input active-high
line 159: "PAG.03" unused input active-high
line 160: "PAG.04" unused input active-high
line 161: "PAG.05" unused input active-high
line 162: "PAG.06" unused input active-high
line 163: "PAG.07" unused input active-high
gpiochip1 - 32 lines:
line 0: "PAA.00" unused input active-high
line 1: "PAA.01" unused input active-high
line 2: "PAA.02" unused input active-high
line 3: "PAA.03" unused input active-high
line 4: "PAA.04" unused output active-high
line 5: "PAA.05" "regulator-vdd-3v3-pcie" output active-high [used]
line 6: "PAA.06" unused input active-high
line 7: "PAA.07" unused input active-high
line 8: "PBB.00" unused input active-high
line 9: "PBB.01" unused input active-high
line 10: "PBB.02" unused input active-high
line 11: "PBB.03" unused output active-high
line 12: "PCC.00" unused output active-high
line 13: "PCC.01" unused output active-high
line 14: "PCC.02" unused output active-high
line 15: "PCC.03" unused output active-high
line 16: "PCC.04" unused input active-high
line 17: "PCC.05" unused input active-high
line 18: "PCC.06" unused input active-high
line 19: "PCC.07" unused input active-high
line 20: "PDD.00" unused input active-high
line 21: "PDD.01" unused input active-high
line 22: "PDD.02" unused input active-high
line 23: "PEE.00" unused input active-high
line 24: "PEE.01" unused input active-high
line 25: "PEE.02" unused input active-high
line 26: "PEE.03" unused input active-high
line 27: "PEE.04" "Power" input active-low [used]
line 28: "PEE.05" unused input active-high
line 29: "PEE.06" unused input active-high
line 30: "PEE.07" unused input active-high
line 31: "PGG.00" unused input active-high
sourav@MTP-SOURAV:~$ sudo gpiofind "PH.00"
gpiochip0 43
sourav@MTP-SOURAV:~$ sudo gpioget gpiochip0 43
0
Tell me what should I do to enable the pins and make them work.
please configure the pinmux by using jetson io tools first.
After that, you could try to use gpiod (gpioset) to control the GPIO first instead of jetson-GPIO. That one is a rather simple one.
Pin 33 is PH.00
Pin 35 is PI.02
Pin 36 is PR.05
Selected manually first.
Showing the selected ones correctly, then I exported as DTO and you can see below it is same as previous configuration, not changing anything.
Also after that I did;
$ gpioget `gpiofind "PH.00"`
0
What else I am missing?
srmohapatra9348:
What else I am missing?
you should save “pin changes” and do a reboot for the changes to take effect I suppose
Saved and rebooted but still not working.
Do you expect those 3 GPIOs to all be output?
Yeah all 3 to be output.
You can see the image below after rebooting when It started from custom 40 pin header config it shows mounting failed but primary kernel works fine but without pin changes;
Please go back to primary kernel to let it boot up fine first.
And just to clarify the usage.
“gpioget” will set the GPIO direction to input. So if you run it, that GPIO won’t be in output mode.
You should use commands similar to below one. And check /sys/kernel/debug/gpio to confirm if it is output high. Then check with multimeter.
gpioset --mode=wait gpiofind "PH.00
=1
$ gpioset --mode=wait gpiofind "PH.00=1"
gpioset: invalid offset<->value mapping: PH.00=1
The forum changed the syntax I posted.
Should be something like this.
gpioset --mode=wait `gpiofind "PH.00"`=1
Okay It’s working. But is it possible to set this into a python script?
could you please write a simple script to make it 0 and 1?
Hi,
Previous tests are just for debug. Now we are sure the pinmux is fine.
Now go back to your script, when you run your script, do you see the 3 GPIOs got configured in /sys/kernel/debug/gpio?
It’s always high, can you please write a simple demo code for pin 33 to ON and OFF.
Could you check if jetson-gpio/samples/simple_out.py at master · NVIDIA/jetson-gpio · GitHub is what you are looking for?
It’s the example python code to control GPIO on 40-pins expansion header.
import RPi.GPIO as GPIO
import time
# Pin Definitions
output_pin = 18 # BCM pin 18, BOARD pin 12
what should I keep for pin 33 , in place of 18. Because I kept 33 and got;
$ python motor.py
WARNING: Carrier board is not from a Jetson Developer Kit.
WARNNIG: Jetson.GPIO library has not been verified with this carrier board,
WARNING: and in fact is unlikely to work correctly.
Traceback (most recent call last):
File "/home/sourav/motor.py", line 47, in <module>
main()
File "/home/sourav/motor.py", line 32, in main
GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.HIGH)
File "/usr/local/lib/python3.10/dist-packages/Jetson.GPIO-2.1.9-py3.10.egg/Jetson/GPIO/gpio.py", line 333, in setup
File "/usr/local/lib/python3.10/dist-packages/Jetson.GPIO-2.1.9-py3.10.egg/Jetson/GPIO/gpio.py", line 124, in _channels_to_infos
File "/usr/local/lib/python3.10/dist-packages/Jetson.GPIO-2.1.9-py3.10.egg/Jetson/GPIO/gpio.py", line 124, in <listcomp>
File "/usr/local/lib/python3.10/dist-packages/Jetson.GPIO-2.1.9-py3.10.egg/Jetson/GPIO/gpio.py", line 110, in _channel_to_info_lookup
ValueError: Channel 33 is invalid