How to use Raspberry Pi GPIO pins with OpenSUSE Tumbleweed and other Linux distributions
Written by: Another Guy with a Computer
Date: January 26, 2024
Last Edited: June 29, 2025
Background & Purpose
Contents
Using GPIO pins with OpenSUSE Tumbleweed, Manjaro Arm, Ubuntu for Arm and Linux distributions other than Raspbian is challenging but not difficult. The challenge arises primarily from documentation gaps which lead most people to simply give up and go back to using Raspbian. While Raspbian is suitable and gets the job done for many, one should not feel compelled to give up on their Linux distribution of choice due to documentation gaps. The purpose of this article is to consolidate knowledge from documentation and forum posts into an easy to use check list.
The information provided by this post should allow you to successfully utilize GPIO pins from a clean Operating System installation. Existing installations may require additional steps to get to a state where GPIO pins are operational depending on previous steps taken.
Problem Summary
The problem encountered and resolved with this page is related to access and permission of items within sysfs and procfs file system spaces.
Solution
These steps have been tested with OpenSUSE Tumbleweed and should work with other distributions including Arm editions of Manjaro, Ubuntu and derivatives.
Add system groups
First, groups and memberships need to be established. As an administrative user such as root or with sudo, run the following commands to create the gpio, i2c, input and spi groups.
sudo groupadd -f --system gpio
sudo groupadd -f --system i2c
sudo groupadd -f --system input
sudo groupadd -f --system spi
Add users to groups
The next step is to add the users which should have access to the GPIO pins to the groups created in the previous step. As an administrative user such as root or with sudo, run the following command replacing [username]
with the name of a user which is to have access to the GPIO pins. In the example shown below, the user "raspberry" is added to the groups. To add multiple users, rerun the command changing the username portion according to your needs.
sudo usermod -a -G gpio,i2c,input,spi [username]
Example command: sudo usermod -a -G gpio,i2c,input,spi raspberry
Note: If you would like to verify group memberships, run the id
command. Changes to the currently logged in user will not be reflected in the output from id
until after the user has been logged out and back in.
Example command with output:
$ id raspberry
uid=1001(raspberry) gid=1001(raspberry) groups=1001(raspberry),490(gpio),479(i2c),478(input),477(spi)
Add UDev Rules
Following the creation of system groups and establishing group memberships, it is necessary to establish several UDev rules. The UDev rules which follow were copied directly from the file /etc/udev/rules.d/99-com.rules of a Raspbian installation. Depending on your use case, you may only require a subset of these rules.
Using a text editor, create a file at path /etc/udev/rules.d/99-com.rules
.
Example command: sudo nano /etc/udev/rules.d/99-com.rules
Add the text which follows to file /etc/udev/rules.d/99-com.rules.
SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys/class/gpio && chmod -R g=u /sys/class/gpio'"
SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p && chmod -R g=u /sys%p'"
# PWM export results in a "change" action on the pwmchip device (not "add" of a new device), so match actions other than "remove".
SUBSYSTEM=="pwm", ACTION!="remove", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p && chmod -R g=u /sys%p'"
Save the changes to /etc/udev/rules.d/99-com.rules and exit your text editor. If you used nano, press Control+O followed by Control+X to save the file and exit nano.
Set the file ownership and access permission by running chown and chmod.
sudo chown "root:root" /etc/udev/rules.d/99-com.rules
sudo chmod 660 /etc/udev/rules.d/99-com.rules
Reboot
With the UDev rules in place, it is time to complete the process with a system reboot. The reboot will reload the sysfs and procfs systems and to allow the UDev rules to initialize. Users added to the gpio group should now have access to GPIO pins. See the GPIO page on OpenSUSE's wiki for more information regarding how to read and write to GPIO pins utilizing gpioget
and gpioset
.
Sources and Additional Information
This page is compiled from information found at several sources including:
- ArchLinux Wiki
- OpenSUSE Wiki
- Raspberry Pi Documentation
- Raspbian OS images
- Ubuntu Wiki
- An assortment of forum posts lost to time...
- Relevant XKCD cartoon from 2011: Wisdom of the Ancients or Explain XKCD 979