Grant permission to GPIO ports

Hello dear community.

I am doing a project in which I need to use the GPIO ports but everytime I need to grant permission by running

sudo chmod 666 /sys/class/gpio/gpio388/value

Is there a way to grant permission without running the above command? Is it possible to write the permission in the bash file?
Thank you in advance

hello alberto18_90,

please refer to Topic 144550, for several ways to access GPIOs. such as, kernel APIs, python scripts, C++ samples.
thanks

Thank you @JerryChang
I have followed the step in the link you mention above jetson-gpio
But when I run the sample_out.py I got this error Exception: Cannot find GPIO chip 3160000.i2c/i2c-0/0-0074

I need to mention that I am using the orbitty carrier board with the TX2.

hello alberto18_90,

it’s due to Jetson GPIO it only supports with Developer Kits.

The orbitty carrier board has this pinout:

Also this is the reference table

Every time I have to run echo 388 > /sys/class/gpio/export so I can use the GPIO 388

So I have to grant permission every time.
Do you have an advice?

hello alberto18_90,

you may have kernel driver implementation to control GPIO-388 from low-level driver instead of sysnodes.

Hi @JerryChang
How can I create a kernel? or where I can read about kernels?
Thank you

hello alberto18_90,

please visit Jetson Linux | NVIDIA Developer to download L4T Driver Package (BSP) Sources.
you should also check Kernel Customization chapter for setting up build environment and compile your own kernel image.
you may refer to some standard APIs to access GPIOs from kernel side.
for example,
$L4T_Sources/r32.6.1/Linux_for_Tegra/source/public/kernel/kernel-4.9/include/linux/gpio.h

static inline int gpio_get_value(unsigned int gpio)
{
        return __gpio_get_value(gpio);
}

static inline void gpio_set_value(unsigned int gpio, int value)
{
        __gpio_set_value(gpio, value);
}

dear @JerryChang
Thank you for your answer. This seems to be more complicated than I expected.
I just want to control RGB LED common anode with the TX2 Orbitty carrier board and I do not find any solution to control the RGB led using python.

Do you have any other advice? or Shall I build my own kernel as the only solution?

hello alberto18_90,

to grant permission, you’ll need to build your own kernel to toggle the pin.

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