TX2 GPIO Is not working

Hi

Now I’m trying to use GPIO but I don’t know how to use this.

I fallowed https://www.jetsonhacks.com/nvidia-jetson-tx2-j21-header-pinout/ this link to know GPIO Pin Number and connection with J21 connector

And I did fallowing things
/***********************************************************************************

root@tegra-ubuntu:/sys/class/gpio/gpio301# echo 1 > value
root@tegra-ubuntu:/sys/class/gpio/gpio301# grep 389 /sys/kernel/debug/gpio
gpio-389 ( |sysfs ) out hi
root@tegra-ubuntu:/sys/class/gpio/gpio301# echo 0 > value
root@tegra-ubuntu:/sys/class/gpio/gpio301# grep 389 /sys/kernel/debug/gpio
gpio-389 ( |sysfs ) out lo

***********************************************************************************/

It looks like working but when I check the pin J21 pin number 33 but it always LOW

Am I checked wrong pin or typed wrong command ?

Thanks.

Everything below of course assumes “sudo”…I use “sudo -s”.

You’re in the wrong directory. You’re trying to use 389 in the 301 directory. 389 doesn’t exist until you export it. To see what is currently available:

cat /sys/kernel/debug/gpio

The numbered directories which are subdirectories of “/sys/class/gpio/” don’t exist until exported. To export 389:

cd /sys/class/gpio/
echo 389 > export
# verify:
egrep 389 <s>cat</s> /sys/kernel/debug/gpio
# Or, note that the gpio389 directory now exists as a symbolic linke:
ls /sys/class/gpio/gpio389

You might be interested in monitoring like this:

watch -n 1 egrep 389 /sys/kernel/debug/gpio

Note that this is by default starting as an output in low state. This is equivalent if not for this being the case already:

echo out > /sys/class/gpio/gpio389/direction
echo 0  > /sys/class/gpio/gpio389/value
# Toggle to 1:
echo 1 > /sys/class/gpio/gpio389/value

Note that J24 selects the 1.8V or 3.3V level shifter (in the corner of the board next to J21). Mine has some hardware issues though with the level shifter (I don’t know if it is the carrier board or the module failing, I suspect my carrier board since this is where the level shifter actually lives). You might experiment with J24. If you have issues too, then you might see “/sys/kernel/debug/gpio” change between hi and lo even though the actual pin only reaches a lower voltage. Mine only works correctly at 1.8V.

Hi linuxdev

Thank you for fast reply !!

I checked J24 selects and I changed 3.3V to 1.8V. But my carrier board still not work even the value return 1 or 0.

export   gpio300  gpio388  gpio395  gpiochip216  gpiochip240  gpiochip448
gpio275  gpio301  gpio389  gpio481  gpiochip224  gpiochip256  unexport
root@tegra-ubuntu:/sys/class/gpio# echo 275 > unexport
root@tegra-ubuntu:/sys/class/gpio# echo 654 > export
bash: echo: write error: Invalid argument
root@tegra-ubuntu:/sys/class/gpio# echo 398 > export
bash: echo: write error: Device or resource busy
root@tegra-ubuntu:/sys/class/gpio# echo 398 > unexport
bash: echo: write error: Invalid argument
root@tegra-ubuntu:/sys/class/gpio# unexport 298
bash: unexport: command not found
root@tegra-ubuntu:/sys/class/gpio# echo 298 > unexport
bash: echo: write error: Invalid argument
root@tegra-ubuntu:/sys/class/gpio# echo 298 > export
root@tegra-ubuntu:/sys/class/gpio# echo 298 > unexport
root@tegra-ubuntu:/sys/class/gpio# echo 554 > export
bash: echo: write error: Invalid argument
root@tegra-ubuntu:/sys/class/gpio# echo 298 > export
root@tegra-ubuntu:/sys/class/gpio# cd gpio298
root@tegra-ubuntu:/sys/class/gpio/gpio298# cat direction
in
root@tegra-ubuntu:/sys/class/gpio/gpio298# cat value
0
root@tegra-ubuntu:/sys/class/gpio/gpio298# echo out direction
out direction
root@tegra-ubuntu:/sys/class/gpio/gpio298# cat value
0
root@tegra-ubuntu:/sys/class/gpio/gpio298# echo 1 > value
bash: echo: write error: Operation not permitted
root@tegra-ubuntu:/sys/class/gpio/gpio298# echo 1 > value
bash: echo: write error: Operation not permitted
root@tegra-ubuntu:/sys/class/gpio/gpio298# ls
active_low  device  direction  edge  power  subsystem  uevent  value
root@tegra-ubuntu:/sys/class/gpio/gpio298# echo 1 value
1 value
root@tegra-ubuntu:/sys/class/gpio/gpio298# echo 0 value
0 value
root@tegra-ubuntu:/sys/class/gpio/gpio298#

I tried to test gpio298 gpio300 gpio388 gpio395 gpio275 gpio301 gpio389 gpio481. All of these pin looks like work in cmd window but the pin out put is always hi or low not changed.

Am I missing something ?

And I checked pin map in this link https://www.jetsonhacks.com/nvidia-jetson-tx2-j21-header-pinout/

hello roikyoun,

you’re able to generate a customize configurations for the GPIOs.
please also download the pinmux spreadsheet from Jetson Download Center for the modification.
you may also check the [NVIDIA Tegra Linux Driver Package]-> [Development Guide]-> [TX2 Configuring Pinmux GPIO and PAD] chapter for the steps.
thanks

I’m not positive, but the numeric designation for gpio number versus physical pin on the carrier board might change depending on release. Be sure to say which L4T release you are using (see “head -n 1 /etc/nv_tegra_release”).

In general, an invalid argument from export probably implies that gpio# doesn’t exist. A device or resource busy would occur if you try to export something already exported…or if the pin isn’t available for GPIO and has something else using it already. If you can’t export due to busy, try unexport first.

After a fresh boot, save a copy of this:

cat /sys/kernel/debug/gpio

Then, if any errors occur, see if this pin shows up in that file as a clue.

I do understand what you mean about seeing the value change in the register, and yet the pin voltage on the carrier board doesn’t behave correctly. I have no workaround for that, but I have found the level shifter can influence this. On the other hand, most of the time the problem is not knowing a correct name-to-pin mapping. This is where the pinmux spreadsheet is comes in, and regardless of whether there is any kind of level shift issue you’d still need to verify first on the pinmux spreadsheet if the change is valid (it’s easy to work without the pinmux to experiment, but when there are errors the spreadsheet is the definitive debug tool). If the pinmux spreadsheet shows you are doing the correct thing, then you can start looking at errors in the level shifter.

Hi linuxdev,

I am also having problems with the level shifter on my board. I am using the cmd line to set a pin on J21 to high or low. When the shifter is set to 1.8V, everything works fine, but when the shifter’s output is set to 3.3V, it does funny things.

Currently I have only a multimeter connected to the pin on J21, and when I set a pin high or low, the output of the shifter gives me somewhere around 1.51V for low, and 1.56V for high (even when J24 is set for 3.3V). The strange thing is that I can make the output 3.3V by temporarily disconnecting the multimeter from the pin, and then reconnecting it. Similarly, I can make the output 0V by setting the pin low from the cmd line (which will initially set the voltage to 1.51V), but when I temporarily disconnect and reconnect the multimeter to the pin, it will then read 0V. This same behavior was reported here https://devtalk.nvidia.com/default/topic/1020887/jetson-tx2/how-to-configure-a-gpio-on-tx2-/post/5213391/#5213391

and

https://devtalk.nvidia.com/default/topic/1030443/jetson-tx2/using-gpio-on-nvidia-jetson-tx2/post/5330619/#5330619

I am wondering if this has something to do with the fact that the TXB0108 level shifter requires +/-2mA to change direction as specified on page 4 of the following app note for the shifter: http://www.ti.com/lit/an/scea043/scea043.pdf

The note states “An external system driver must supply more than ±2 mA of current to reliably overdrive the hold provided by the weak buffer.” It seems that the Jetson maxes out at a 2mA drive current, and I was wondering if this might be part of the problem.

Were you ever able to get the GPIO working properly at 3.3V? I have now tried this with multiple different Jetsons and multiple dev boards and I see the same behavior.

I’ve seen this as well (where the level shifter has problems…my oscilloscope died, so all I have is also a multimeter), but have not looked at it in a long time. My thought is that in some cases you may need a pull up resistor since the register changes as it should. If not, then it is perhaps a level shifter failing, or as you are saying, perhaps some other load range is supported (keep in mind that I have seen the exact thing you’ve seen, but I never investigated). Some of the GPIO worked correctly for me at both 1.8V and 3.3V, others had issues except at 1.8V.

You’ll need to state the exact pin/GPIO you are referring to. For that pin, can someone suggest if any kind of load and/or pull-up/pull-down is required? I can confirm that I have seen similar issues in the past when measuring with essentially no load.

hey guys,

kernel commands were only testing purpose.
please use pinmux spreadsheet to generate cfg file and update the board for GPIO configuration.

you should access pinmux spreadsheet, and please check documentation, Jetson TX2 Pinmux and GPIO Configuration for the steps.

BTW,here’s one more similar discussion thread, Topic 1051717 for your reference,
thanks

In my case this is the default install with no modifications (it’s using the GPIO as provided from an unmodified flash). From what I can tell the correct echo was used, and initially the GPIO does actually show a change, but further changes (despite having the register correctly change) do not correctly change the GPIO voltage under one setting of the level shifter. I believe this is what the original poster has had happen, and I can verify the procedure was correct, but I last looked at this maybe a couple of years ago and don’t remember the details. I do recall though that this appeared to be entirely a level shifter issue. Thus the thought of perhaps a pull-up or pull-down as a workaround.