0

I’m trying to change pin mode on RPI (with Raspbian) – it works when I invoke those commands

sudo chown root.gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem

but after every restart I have to execute them because without this I have this error:

“Setting a mode to a pin requires root permissions. ---> System.UnauthorizedAccessException: Access to the path '/sys/class/gpio/gpio21/direction' is denied. ---> System.IO.IOException: Permission denied”

How can I persist those permissions?

  • What operating system? – joan Jan 3 at 21:42
  • Raspbian (November 2018) – dnf Jan 3 at 22:13
  • You should edit useful information into your question. People shouldn't need to read the comments. You should just add your user to group gpio. Nothing else should be required on Raspbian, i.e. a one off sudo adduser pi gpio. – joan Jan 3 at 22:57
  • I updated my question when I commented post and pi user is already in this group – dnf Jan 3 at 23:00
0

You CAN NOT "persist those permissions" because that is not how Linux works.

The permissions are set by the OS, and should be:-

crw-rw---- 1 root gpio 248, 0 2019-01-01 14:39 /dev/gpiomem

Incidentally the syntax of your chown is incorrect it should be chown root:gpio /dev/gpiomem, but this should be the initial state.

As joan has pointed out group gpio already has write permissions.

  • What is the problem you are complaining? I don't see it. The settings the OP made are just the default settings, isn't? It has no effect. – Ingo Jan 4 at 11:44
  • I can't test it now but I think this is the solution - raspberrypi.stackexchange.com/questions/59371/… – dnf Jan 4 at 13:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.