Xavier NX control GPIO

How can I use Xavier NX’s GPIO using APIS. For instance, what’s the header file I need to include?

When I use the function named gpioSetDirection, it shows that “Permission denied”.

hello VastStar ,

please try below method to access GPIOs.
for example,
Generate gpio220 name under the path of GPIOs
echo 220 > /sys/class/gpio/export
Enable the pin for usage.
echo out > direction && echo 1 > value

Thanks for your reply.
However, It shows Permission denied, when use command “echo out > direction && echo 1 > value”

bash: direction: Permission denied

What troubles me is that I don’t kown how to give it permission.

hello VastStar ,

did you grant root permission for running this?

nvidia@nx-jp440:/sys/class/gpio$ echo 417 > /sys/class/gpio/export 
nvidia@nx-jp440:/sys/class/gpio$ echo out >direction && echo 1 > value
bash: direction: Permission denied
nvidia@nx-jp440:/sys/class/gpio$ su
root@nx-jp440:/sys/class/gpio# echo out > direction
bash: direction: Permission denied

I don’t kown whether is correct or not.

Hi @VastStar ,

Have you tried like below?

sudo echo 417 > /sys/class/gpio/export
sudo echo out > direction && sudo echo 1 > value


I have tried but got the same result.

Can you type below command?

sudo chmod +x /sys/class/gpio/gpio417/direction
sudo chmod +x /sys/class/gpio/gpio417/value

It works. But 22Pin(gpio417) has no output.

Hello @VastStar

If you don’t want to change permissions or anything you can use the following commands:

sudo sh -c "echo 417 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/gpio417/direction"
sudo sh -c "echo 0 > /sys/class/gpio/gpio417/value"

This will run the command that you specify after the -c flag in a new shell with super user permissions and execute it. Maybe you can check with that too and see if the issue is still there.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.