19.10 how do I set permissions for libgpiod

Asked by Steve Foxover

I have installed Ubuntu server 19.10 on RPi4 hardware. I want to test the libgpiod lib to access sensor hardware. gpiodetect and other tools require sudo access.

How can I access /dev/gpiochip0 from userland without sudo access?

Does it require a custom kernel build?

Thanks

Steve

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu linux-raspi2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Steve Foxover (sfoxover) said :
#1

After running
sudo chown root.gpio /dev/gpiochip*
sudo chmod g+rw /dev/gpiochip*

It works, but this change gets reverted after a reboot.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

If you form a /etc/rc.local file to run the commands at boot then it will sort this for you.

Run:

sudo vi /etc/rc.local; sudo chmod +x /etc/rc.local

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

Add the below 4 lines:

#!/bin/sh -e
chown root.gpio /dev/gpiochip*
chmod g+rw /dev/gpiochip*
exit 0

Save the new file, exit vi and reboot. Obviously change vi for your favourite text editor if you want

Revision history for this message
Steve Foxover (sfoxover) said :
#4

Thank you so much for your quick response.
Steve

Can you help with this problem?

Provide an answer of your own, or ask Steve Foxover for more information if necessary.

To post a message you must log in.