Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power GPIO permission denied #249

Closed
dvino opened this issue Oct 17, 2021 · 2 comments
Closed

Power GPIO permission denied #249

dvino opened this issue Oct 17, 2021 · 2 comments

Comments

@dvino
Copy link

dvino commented Oct 17, 2021

Power GPIO permission denied.
Config:

[power printer]
type: gpio
pin: gpiochip0/gpio6
initial_state: off

Klipper not use any GPIO. If I try control GPIO by bash it work perfect. Moonraker works under the same user.

I attach the moonraker.log file immediately after the reboot

OS: Armbian 21.08.3 Bullseye
Board: Orange PI Zero

/etc/systemd/system/moonraker.service

#Systemd service file for moonraker
[Unit]
Description=API Server for Klipper
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=danil
Group=gpio
RemainAfterExit=yes
WorkingDirectory=/home/danil/moonraker
ExecStart=/home/danil/moonraker-env/bin/python /home/danil/moonraker/moonraker/moonraker.py -c /home/danil/klipper_config/moonraker.conf -l /tmp/moonraker.log
Restart=always
RestartSec=10

/etc/udev/rules.d/99-gpio.rules

SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
    chown -R root:gpio /sys/class/gpio && chmod -R 0770 /sys/class/gpio &&\
    chown -R root:gpio /sys/devices/platform/soc && chmod -R 0770 /sys/devices/platform/soc'" 

ls -l /sys/class/gpio/

-rwxrwx--- 1 root gpio 4096 окт 17 23:08 export
lrwxrwxrwx 1 root gpio    0 окт 17 23:01 gpiochip0 -> ../../devices/platform/soc/1c20800.pinctrl/gpio/gpiochip0
lrwxrwxrwx 1 root gpio    0 окт 17 23:01 gpiochip352 -> ../../devices/platform/soc/1f02c00.pinctrl/gpio/gpiochip352
-rwxrwx--- 1 root gpio 4096 окт 17 23:09 unexport

id
uid=1000(danil) gid=1000(danil) groups=1000(danil),5(tty),6(disk),20(dialout),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),102(systemd-journal),106(input),110(netdev),112(ssh),118(mnrkrsudo),1001(gpio)

@dvino
Copy link
Author

dvino commented Oct 18, 2021

If I do sudo chmod 4775 /usr/bin/python3.9 it works perfect

@dvino
Copy link
Author

dvino commented Oct 18, 2021

Problem was to access /dev/gpiochip*

Solution:
Create a file /etc/udev/rules.d/60-gpiod.rules containing the following:

# udev rules for gpio port access through libgpiod
SUBSYSTEM=="gpio", KERNEL=="gpiochip[0-4]", GROUP="gpio", MODE="0660"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant