Hi,
Can you please help me with a C++ code including headers to toggle pin 23 - SPI_SCLK continously ?
Thanks,
Pratosha
Hi,
Can you please help me with a C++ code including headers to toggle pin 23 - SPI_SCLK continously ?
Thanks,
Pratosha
@spin_interrupt
I am experiencing the same issues: The GPIOs on J21 did work but now they donāt anymore. I have gpiochip488 under /sys/class/gpio. How did you fix that?
One issue I found is that the level shifter may change reliablability. If you look at J24 this optionally selects between 3.3V TTL levels and 1.8V. In terms of software commands doing an echo into ā/sysā gpio files this will not matterā¦but output levels may show correct behavior at 3.3V even when not correct at 1.8V. Check this jumper and test the output reliability at both 1.8V and 3.3Vā¦see if one is reliable even when the other is not. Iām not positive (it was quite some time back), but I think it was 3.3V which was working for me.
Hi linuxdev,
I have configued the GPIO Pin37( gpio388) on TX2 ,with the following step:
cd /sys/class/gpio
echo 388 > export
cd gpio388
echo out > direction
echo 1 > value
cat value
1
My target is that ,Driving a small steper motor & led, but why , nothing happened .
what I should to do ???
to make gpio388 out with high voltage(3.3v)
Check with a voltmeter and see if manually changing 1/0 works with essentially no load. Monitor ādmesg --followā while doing so.
It may be that if this succeeds you need to add a buffer to your stepper.
hi linuxdev,
i check pin37 voltage with voltmeter, but whatever value be setted (1or0) ,the output voltage is 3.19v
if i changed to connect the motor with pin39 and pin1,the motor work fine.the voltage is 3.3v
what i should to do,more
This may be a bug or issue, but youāll want to first state if you have any device tree modifications. After that give the exact pin you are checking voltage on, the L4T release you are using (āhead -n 1 /etc/nv_tegra_releaseā), and the commands you are using in ā/sysā. With that combination of information something could be verified.
1 I have changed nothing about device treeć
2
root@tegra-ubuntu:/sys/class/gpio# echo 388 > export
root@tegra-ubuntu:/sys/class/gpio# cd gpio388
root@tegra-ubuntu:/sys/class/gpio/gpio388# ls
active_low device direction edge power subsystem uevent value
root@tegra-ubuntu:/sys/class/gpio/gpio388# cat direction
out
root@tegra-ubuntu:/sys/class/gpio/gpio388# echo 1 > value
root@tegra-ubuntu:/sys/class/gpio/gpio388# cat value
1
root@tegra-ubuntu:/sys/class/gpio/gpio388# head -n 1 /etc/nv_tegra_release
root@tegra-ubuntu:/sys/class/gpio/gpio388#
Which pin are you measuring voltage on to see if it reflects the state change?
Refer to the following maping table
the PIN37/port388/GPIO26 is used by me!
thanks alot!
My TX2 dev board (R28.2) works correctly with the above. My J24 jumper is set for 3.3V level shifter (pins furthest from the board corner are jumpered). Are your J24 jumpers the same? If you measure the voltage on the jumper itself in that position is it 3.3V?
Just something to cross checkā¦this will verify what you think the state of gpio-388 is:
sudo -s
watch -n 1 egrep 388 /sys/kernel/debug/gpio
exit
If 3.3V does not work try shutting down, remove power, discharge a few seconds with the power button, change J24 to 1.8V position, and try againā¦then back to 3.3V. Does this finally work at 3.3V? I have had trouble in the past on 1.8V.
if I change J24 to 1.8V position, and measure the voltage on the jumper24 itself in that position. it is 0.8V.
if I change J24 to 3.3V position, and measure the voltage on the jumper24 itself in that position. it is 2.35V.
after I change J24 to 1.8v position ,and then change J24 to 3.3V position, I can measure the change of gpio388 voltage .
so , I think , the root reason is gpio388 have no enough power to driver my steper_motor.
now , instead of gpio388, I used the GPIO466 , the stepper_motor work fine !
thanks a lot!
Ahh! I did not know there was a stepper directly connected. Yes, put a buffer on thatā¦GPIO wasnāt meant to drive a motor (it might drive it, it depends on the specific case).
The Jetson GPIO pins are rated at only one or two milliamps of current. Some of the pins use voltage level translators that may be rated for slightly more, but I wouldnāt expect a drive capability of anything above 6 mA or so.
If you try to drive a heavy load, you will burn out parts of the motherboard, or even parts of the Jetson.
Thereās another risk with motors (and relays, and other inductive devices): back EMF. For example, if the motor is rotated when not powered, it will work as a generator, and will generate a voltage into the Jetson motherboard that is potentially a lot higher than what the pins are rated for.
When driving electromechanical parts, ALWAYS use a separate driver! Else you will destroy your expensive computer hardware. Examples of affordable drivers include the various Texas and LM chips (LM298, TI8825, and so forth.) You can buy these reasonably inexpensively from places like Pololu or Sparkfun, or even cheaper from places like ebay and banggood.
thanks linuxdev and sharky
from now on,i will use gpio388 as a on/off signal only .
I tried exporting pin 35(gpio395), pin 37(gpio388), pin 40(gpio393), and pin 29(gpio398) and setting the value to 1 and direction to out, and cat shows the correct values. But only pin29 works with giving me the digital output I need. Using a voltmeter on pin37 shows 0.01V, which is really puzzling because it should work according to the above comments. Any ideas?
Also, I need 12 digital outputs. Is J21 able to provide that many, or should I try some other header ports? If so, please advise on how!
Thanks
Some pins may already be in use and unless removed from that other function they wonāt be available. I assume you are talking about J21 on the dev board? Under R28.2.1?
I havenāt checked if those are actually the correct pins for those particular gpio. How did you determine/map which pin belongs to which gpio number for export?
Before you try to export a GPIO be sure it isnāt already in ā/sys/kernel/debug/gpioā, and then after export check again for both existence and direction.
I have seen cases where the level shifter does not always seem to perform as it should. Some I/O is selectable between 1.8V and 3.3V via J24 and I found 3.3V worked when 1.8V did not, but I never investigated it further.
Yes Iām talking about J21, but I think my jetpack version is 28.2.0?
ā# R28 (release), REVISION: 2.0, GCID: 10136452, BOARD: t186ref, EABI: aarch64, DATE: Fri Dec 1 14:20:33 UTC 2017ā
I used the GPIO mapping in NVIDIA Jetson TX2 J21 Header Pinout - JetsonHacks
And now not even pin 29 is working for me!
I did what you said and checked ā/sys/kernel/debug/gpioā, and everything was as you said:
before exporting 396 (pin 7) and 398 (pin 29) for example, I get
GPIOs 320-511, platform/2200000.gpio, tegra-gpio: gpio-381 ( |reset_gpio ) out lo gpio-412 ( |vdd-usb0-5v ) out lo gpio-413 (
after exporting, I get
GPIOs 320-511, platform/2200000.gpio, tegra-gpio: gpio-381 ( |reset_gpio ) out lo gpio-396 ( |sysfs ) out hi gpio-398 ( |sysfs ) out hi gpio-412 ( |vdd-usb0-5v ) out lo gpio-413 (
but neither of them turn on my test LED and when testing with a voltmeter I get a very low voltage like 0.06V.
I also tried echoing the value and direction in ā/sys/devices/2200000.gpio/gpio/gpio398ā for example, and it didnāt work.
Also I tried shifting the jumper on J24 in both positions, pins 1-2 (default) which is supposed to set the I/O to 3.3V and pins 2-3 for 1.8V, and nothing changed on my voltmeter.
Iām completely stumped?
For reference, I am using this for my pinout:
https://www.jetsonhacks.com/nvidia-jetson-tx2-j21-header-pinout/
Looking at these pins of J21:
pin 31: GPIO298
pin 33: GPIO389
pin 37: GPIO388
First, make sure the voltage to pins 1 and 3 of J24 are working. This is the power to the level select jumper, so pin 1 is 3.3V and pin 3 is 1.8V. If these are not up, then nothing will work. I am using 3.3V.
Next, know that an LED probably exceeds the load capacity of GPIO. You shouldnāt use an LED directly on this pin (even with a resistor). Though not likely, it might be possible you could even damage the level shifter when drawing too much current. Use a buffer or driver.
For reference, I am using āsudo -sā to drop into a root shell for all of this. Itās easier than using āsudoā on every line.
Each time you want to see the current status of one of these run this command:
egrep '(298|388|389)' /sys/kernel/debug/gpio
Pin 31, GPIO298:
echo '298' > /sys/class/gpio/export
echo 'out' > /sys/class/gpio/gpio298/direction
echo '1' > /sys/class/gpio/gpio298/value
egrep '(298|388|389)' /sys/kernel/debug/gpio
# implies gpio-298 ( |sysfs ) out hi
# Pin 31 is 3.3V
echo '0' > /sys/class/gpio/gpio298/value
egrep '(298|388|389)' /sys/kernel/debug/gpio
# implies gpio-298 ( |sysfs ) out lo
# Pin 31 is about 90mV
Same for pin 33 (GPIO389)ā¦
echo '389' > /sys/class/gpio/export
echo 'out' > /sys/class/gpio/gpio389/direction
echo '1' > /sys/class/gpio/gpio389/value
egrep '(298|388|389)' /sys/kernel/debug/gpio
# implies gpio-389 ( |sysfs ) out hi
# Pin 31 is 3.3V
echo '0' > /sys/class/gpio/gpio389/value
egrep '(298|388|389)' /sys/kernel/debug/gpio
# implies gpio-389 ( |sysfs ) out lo
# Pin 31 is about 90mV
And pin 37 (GPIO388)ā¦
echo '388' > /sys/class/gpio/export
echo 'out' > /sys/class/gpio/gpio388/direction
echo '1' > /sys/class/gpio/gpio388/value
egrep '(298|388|389)' /sys/kernel/debug/gpio
# implies gpio-388 ( |sysfs ) out hi
# Pin 31 is 3.3V
echo '0' > /sys/class/gpio/gpio388/value
egrep '(298|388|389)' /sys/kernel/debug/gpio
# implies gpio-388 ( |sysfs ) out lo
# Pin 31 is about 90mV
Earlier I did not know you had an LED on it. If you have issues without the LED it might be a problem, but I would expect any significant load to cause voltage measurements to be off. Iām not sure how software would react under too much load.