wiringOP
wiringOP copied to clipboard
Access gpios without root access
Hey, I have tested wiringOP on armbian running on an orange pi zero LTS. I tried to access GPIOs as a non-root user but can't seem to do so.
wiringPiSetup: Unable to open /dev/mem or /dev/gpiomem: No such file or directory.
Aborting your program because if it can not access the GPIO
hardware then it most certianly won't work
Try running with sudo?
Running user space software with sudo is clearly not what I want.
I tried already adding the group gpio
and adding the user to that. I also changed permissions of /dev/mem
from
crw-r----- 1 root kmem 1, 1 Nov 3 16:59 /dev/mem
to
crw-rw---- 1 root gpio 1, 1 Nov 3 16:59 /dev/mem
as I read in some post but that also didn't fix it. So how can I fix this?
I suggest @orangepi-xunlong make /dev/gpio in their Ubuntu release. At this time I need access to /dev/mem to get GPIO adresses: open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC). This is wrong way because badboy can read ram... But at this time this is only one way to call wiringPiSetup() in my app. My executable app has name test; I am in their folder. 0 sudo userchmod -aG kmem and reboot 1 sudo setcap cap_sys_rawio,cap_dac_override=ep ./test 2 @orangepi-xunlong you should close /dev/mem after mmap registers, isn't it? So you should add
int wiringPiSetup (void)
...
initialiseEpoch () ;
close(fd); //close /dev/mem
return 0 ;
}
P.S. I use Orange Pi 4B
@HerrMuellerluedenscheid Were you able to solve this issue, I just get the OrangePi and as well as you I need to run Gpio without root permissions.
Has anyone been able to solve the problem?
Anyone solved this? @orangepi-xunlong we need user access to GPIO in wiringPi not sudo on the OrangePi 5b.
Anyone solved this? @orangepi-xunlong we need user access to GPIO in wiringPi not sudo on the OrangePi 5b.
@orangepi-xunlong
+1
PS for the moment I'm using the following launch.json in vscode. Not ideal but it does allow for debugging break points
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug-Python",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"program": "${file}",
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"debugOptions": [
"RedirectOutput",
"Sudo"
]
},
]
}
https://github.com/orangepi-xunlong/wiringOP/issues/28 sudo setcap cap_sys_rawio,cap_dac_override=ep ./test
Any update?
Having issues with this trying to access gpio pins from a ros 2 node.