Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4874

Troubleshooting • Is there a way to use RPi._GPIO in docker without --privileged?

$
0
0
It used to work, but after upgrading restarting the container recently it stopped working. I don't know what changed. I'm getting this error:

Code:

  File "<stdin>", line 1, in <module>  File "/usr/local/lib/python3.11/dist-packages/RPi/GPIO/__init__.py", line 23, in <module>    from RPi._GPIO import *RuntimeError: This module can only be run on a Raspberry Pi!
What I don't understand is in the GPIO library's source code. This is where it happens:

https://github.com/metachris/RPIO/blob/ ... pio.c#L536

and one could trace it to here:

https://github.com/metachris/RPIO/blob/ ... info.c#L46

One could see that it's getting that error because this function is failing to get the revision and hardware. However, the way it gets the revision is using

Code:

cat /proc/cpuinfo
Though it's completely possible to do that in both the host and the guest (in docker). There's no access issue. However, both don't have the line BCM2708... here's the output:

Code:

processor: 0BogoMIPS: 108.00Features: fp asimd evtstrm crc32 cpuidCPU implementer: 0x41CPU architecture: 8CPU variant: 0x0CPU part: 0xd08CPU revision: 3processor: 1BogoMIPS: 108.00Features: fp asimd evtstrm crc32 cpuidCPU implementer: 0x41CPU architecture: 8CPU variant: 0x0CPU part: 0xd08CPU revision: 3processor: 2BogoMIPS: 108.00Features: fp asimd evtstrm crc32 cpuidCPU implementer: 0x41CPU architecture: 8CPU variant: 0x0CPU part: 0xd08CPU revision: 3processor: 3BogoMIPS: 108.00Features: fp asimd evtstrm crc32 cpuidCPU implementer: 0x41CPU architecture: 8CPU variant: 0x0CPU part: 0xd08CPU revision: 3Revision: c03111Serial: 10000000c1393c25Model: Raspberry Pi 4 Model B Rev 1.1
But then why does it work in the host, not the guest? What am I missing? I want to avoid having this app run in privileged mode.

Statistics: Posted by Gumdrop — Wed Jul 31, 2024 7:27 pm



Viewing all articles
Browse latest Browse all 4874

Trending Articles