PI-OS GPIO direction interface failing after OS upgrade. Why?

42 views Asked by At

Servlet requires nonprivileged access. Tomcat was added to gpio group and udev rules applied. But after kernel update to Linux pihive1 6.1.61+ #1696 Thu Nov 2 16:33:31 GMT 2023 armv6l GNU/Linux on

Raspberry Pi Details:
  Type: Pi Zero-W, Revision: 01, Memory: 512MB, Maker: Sony 
  * Device tree is enabled.
  *--> Raspberry Pi Zero W Rev 1.1
  * This Raspberry Pi supports user-level GPIO access.

servlet reports exception:

Nov 17 14:17:57 pihive1 tomcat9[484]: java.lang.RuntimeException: Unable to open GPIO direction interface for pin [22]: Permission denied
Nov 17 14:17:57 pihive1 tomcat9[484]:         at com.pi4j.wiringpi.GpioUtil.export(Native Method)
Nov 17 14:17:57 pihive1 tomcat9[484]:         at com.pi4j.io.gpio.WiringPiGpioProviderBase.export(WiringPiGpioProviderBase.java:108)

Adapting /etc/udev/rules.d/99-com.rule by adding /dev/gpiomem

$ diff backup-99-com.rules /etc/udev/rules.d/99-com.rules
10c10,11
<       chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\
---
>       chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath;\
>         chown root:gpio /dev/gpiomem && chmod g+rw /dev/gpiomem\

solved the problem, but assumption was that pi4j uses same deprecated sysfs approach as python gpio lib. Did I miss something?

Note: the "first try fails" - topic mentioned in Raspberry pi GPIO sysfs, fopen: Permission denied persists but is acceptable.

0

There are 0 answers