Hi, I’m trying to access gpio using libgpiod on TX2 with dev kit. I have an application that works fine running with sudo. If I run without I get an access error. My user is called tx2. It seems like the udev rules are not firing during boot as the permissions for gpio stay with root:root whereas they should be root:gpio? Any ideas why this is not working or how to fix?
Thanks in advance,
Felix
Relevant terminal output below:
$ cat /etc/nv_tegra_release
# R32 (release), REVISION: 7.5, GCID: 36557527, BOARD: t186ref, EABI: aarch64, DATE: Tue Jun 11 23:18:04 UTC 2024
$ ls -l /dev/gpio*
crw------- 1 root root 254, 0 Nov 12 10:00 /dev/gpiochip0
crw------- 1 root root 254, 1 Nov 12 10:00 /dev/gpiochip1
crw------- 1 root root 254, 2 Nov 12 10:00 /dev/gpiochip2
crw------- 1 root root 254, 3 Nov 12 10:00 /dev/gpiochip3
crw------- 1 root root 254, 4 Nov 12 10:00 /dev/gpiochip4
$ ls -l /sys/class/gpio
total 0
--w--w---- 1 root gpio 4096 Nov 12 10:00 export
lrwxrwxrwx 1 root root 0 Nov 12 10:00 gpiochip216 -> ../../devices/bpmp_i2c/i2c-4/4-003c/max77620-gpio/gpio/gpiochip216
lrwxrwxrwx 1 root root 0 Nov 12 10:00 gpiochip224 -> ../../devices/3160000.i2c/i2c-0/0-0077/gpio/gpiochip224
lrwxrwxrwx 1 root root 0 Nov 12 10:00 gpiochip240 -> ../../devices/3160000.i2c/i2c-0/0-0074/gpio/gpiochip240
lrwxrwxrwx 1 root root 0 Nov 12 10:00 gpiochip256 -> ../../devices/c2f0000.gpio/gpio/gpiochip256
lrwxrwxrwx 1 root root 0 Nov 12 10:00 gpiochip320 -> ../../devices/2200000.gpio/gpio/gpiochip320
--w--w---- 1 root gpio 4096 Nov 12 10:00 unexport
$ ls /lib/udev/rules.d/*gpio*
/lib/udev/rules.d/60-jetson-gpio-common.rules
$ cat /lib/udev/rules.d/60-jetson-gpio-common.rules
# Copyright (c) 2012-2017 Ben Croston <ben@croston.org>.
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", \
PROGRAM="/bin/sh -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", DEVPATH=="/*/gpiochip*/gpio/*", ACTION=="add", \
PROGRAM="/bin/sh -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"
SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="add", \
PROGRAM="/bin/bash -c 'chown root:gpio /sys%p/{,un}export; chmod 220 /sys%p/{,un}export'"
SUBSYSTEM=="pwm", KERNEL=="pwmchip*", ACTION=="change", \
PROGRAM="/bin/bash -c 'chown root:gpio /sys%p/%E{EXPORT}/{period,duty_cycle,enable}; chmod 660 /sys%p/%E{EXPORT}/{period,duty_cycle,enable}'"
SUBSYSTEM=="spidev", KERNEL=="spidev*", ACTION=="add", \
GROUP="gpio", MODE="0660"
$ groups tx2
tx2 : tx2 adm dialout cdrom sudo audio dip video plugdev i2c lpadmin gdm lightdm gpio weston-launch sambashare gpiod
I also tried appending
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", \
PROGRAM="/bin/sh -c 'chown root:gpio /dev/%k; chmod 660 /dev/%k'"
to the end of the 60-jetson-gpio-common.rules file but that did not help.