I have installed the ubuntu core on a Raspberry3 and made a snap app about operating the rasp’s gpio pins.
But there will be an error ("RuntimeError: No access to /dev/mem. Try running as root!
" ) when I try to run the snap app.
The python file contains a very simple function, which is to turn the gpio pins on and off.
I try to solve it by the following command lines
" sudo adduser myusername gpio
sudo chown myusername /dev/gpiomem
sudo chmod g+rw /dev/gpiomem
"
emmmm… it made no sense.
So how can I solve the problem??? And what’i more ,why it happened???
gpiomem access is actually granted automatically when using a gpio interface … that said, i think you need to use a pi image from edge to even get these interfaces since the gadget snap in stable does not provide them.
Thanks for your careful answer
I have tried adding plugs after the corresponding directives in the snapcraft.yaml, but this doesn;t seem to work,I added some interfaces to the file(gpio-memory-control ; gpio ; physical-memory-control ; physical-memory-observe) in order to grant the snap app access to the /dev/gpiomem and /dev/mem.
Following is the configuration of my app:
emmmm… hahahaha
I come back (⁎⁍̴̛ᴗ⁍̴̛⁎)
I have solved this problem.
After adding the relevant interface description, you still need to use “sudo your-snap-command” to let the app access the gpio pins.
Thanks again for your answer
eventually we should be able to assign all gpio access to a certain group or have it grant access via udev-acl’s so you wont need sudo for your snap command anymore.