Raspberry Pi: GPIO as a user

In Raspbian (from which a lot of Raspberry Pi developers are coming), while sudo is required to access /dev/mem, it’s not required to access /dev/gpiomem. However, in Ubuntu Core sudo is still required. This is protected by an interface either way, but it would be nice to have feature parity with Raspbian here to make developing snaps on device easier. I’d like to see /dev/gpiomem accessible as a user. Thoughts?

1 Like

To answer your question directly, you need a udev rule or similar to set the permissions on /dev/gpiomem the way you want them.

Googling reveals that the device is actually 0660 root:gpio so the user would need to be in the gpio group to access the pins. This is sane.

However, the gpio group does not exist on core and snappy doesn’t yet allow adding users and groups to the system. This is on the roadmap though and part of Multiple users and groups in snaps (see use case ‘2’), so this will be supported in the gpio-memory-control interface where it would add the group to the system with an ACL to allow users in that group to access the device.

As mentioned elsewhere, the design is complete and on the roadmap, but not prioritized. It is something I’m trying to do in the background, but progress is slow due to prioritized items.

1 Like

Awesome! No big rush here, just something that’s been annoying me the last few days. Thanks for the details, @jdstrand, glad to see it’ll work better eventually :slight_smile: .