From 9310ba7e17f97c4570dce33552b3605155ca5c0c Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Fri, 24 Jan 2025 21:43:56 +0000 Subject: Adds UDEV rules for root-less GPIO and PWM access --- udev/98-gpiod.rules | 2 ++ udev/99-pwm.rules | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 udev/98-gpiod.rules create mode 100644 udev/99-pwm.rules (limited to 'udev') diff --git a/udev/98-gpiod.rules b/udev/98-gpiod.rules new file mode 100644 index 0000000..4961d33 --- /dev/null +++ b/udev/98-gpiod.rules @@ -0,0 +1,2 @@ +# Grants GPIO access to the gpio group. +SUBSYSTEM=="gpio", KERNEL=="gpiochip*", GROUP="gpiod", MODE="0660" diff --git a/udev/99-pwm.rules b/udev/99-pwm.rules new file mode 100644 index 0000000..2b95f14 --- /dev/null +++ b/udev/99-pwm.rules @@ -0,0 +1,10 @@ +# Grants PWM access to the pwm group. Because UDEV is async, there might be a +# slight delay between changes to the directory tree (e.g., a new PWM channel +# being added) and changes to permissions taking effect. The command +# `udevadm settle` can be used to wait for the rule to finish execution. +SUBSYSTEM=="pwm*", PROGRAM="/bin/sh -c ' \ + chown -R root:pwm /sys/class/pwm ; \ + chmod -R 770 /sys/class/pwm ; \ + chown -R root:pwm /sys/devices/platform/axi/1000120000.pcie/*.pwm/pwm/pwmchip* ; \ + chmod -R 770 /sys/devices/platform/axi/1000120000.pcie/*.pwm/pwm/pwmchip* ; \ +'" -- cgit v1.2.1