Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] Can't access Raspberry Pi 4 GPIO's in container without sudo #1297

Open
DPaess opened this issue Mar 19, 2024 · 2 comments
Open

[Error] Can't access Raspberry Pi 4 GPIO's in container without sudo #1297

DPaess opened this issue Mar 19, 2024 · 2 comments
Labels
bug Something isn't working wait-on-user waiting for a reply

Comments

@DPaess
Copy link

DPaess commented Mar 19, 2024

I'm trying to deploy a distrobox container in Raspberry Pi 4 with Raspberry Pi OS using a distrobox container with the following command: distrobox-create --root --image docker.io/library/ros:humble-ros-base-jammy --name humbleV1 --home ~/containers/humbleV1. Inside the container I make sure to install (or update) lgpio and gpiozero. I've set up a python script,teste.py, to test it which consists of simple 3 lines from gpiozero import LED \n led = LED(17) \n led.toggle(). When I run this script with sudo teste.py it works but when I don't use sudo it doesn't work, and I can't use sudo because I need to run this script via ROS2. Any ideias? I tried some flags of distrobox (unshare-process,unshare-netns,unshare-devsys) and messing with group access but it didn't work. The error is in the image bellow ( it sometimes runs another one that cant find pin factory but it changes to this after setting pin factory with the command export GPIOZERO_PIN_FACTORY=lgpio)
image

@DPaess DPaess added the bug Something isn't working label Mar 19, 2024
@89luca89
Copy link
Owner

Hi @DPaess

the user inside the container does not have the same groups as outside
so you should add yourself to the same groups also inside, in this case, to access the GPIO

@89luca89 89luca89 added the wait-on-user waiting for a reply label Mar 25, 2024
@DPaess
Copy link
Author

DPaess commented Mar 28, 2024

Hi @DPaess

the user inside the container does not have the same groups as outside so you should add yourself to the same groups also inside, in this case, to access the GPIO

I already tried that, inside the container we have ubuntu which uses dialout group to acess gpio pins but adding the user to this group is not solving the problem as you can see below:
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wait-on-user waiting for a reply
Projects
None yet
Development

No branches or pull requests

2 participants