Debug application as sudo ?
-
wrote on 22 Mar 2021, 08:59 last edited by Alan B
I am developing an application which uses the pigpio library and so needs to run as sudo in order to gain permission to the GPIO pins. Is there a way to run from the debugger in this mode?
-
I am developing an application which uses the pigpio library and so needs to run as sudo in order to gain permission to the GPIO pins. Is there a way to run from the debugger in this mode?
@Alan-B Did you try to start debugger with sudo?
-
I am developing an application which uses the pigpio library and so needs to run as sudo in order to gain permission to the GPIO pins. Is there a way to run from the debugger in this mode?
wrote on 22 Mar 2021, 09:28 last edited by@Alan-B
I know nothing about GPIO, pins or otherwise!But is it worth reading, say, https://raspberrypi.stackexchange.com/questions/40105/access-gpio-pins-without-root-no-access-to-dev-mem-try-running-as-root ? Suggestions like making your non-sudo user a member of
gpio
group to allow access? -
@jsulm I added the '-e sudo' option to Tools | Options | Environment | System | Terminal but still no joy.
Also, pi appears to already be a member of the gpio group so I'm a bit stumped as to what to try next.
@Alan-B Did you check what is the group of the device file for gpio is (I don't know how that /dev/* file is called)? Also, check whether this group actually has read/write access to the device file.
-
wrote on 22 Mar 2021, 14:48 last edited by
@jsulm if I run 'ls -l /dev/gp*' I get the following:
crw-rw---- 1 root gpio 254, 0 Mar 22 12:57 /dev/gpiochip0
crw-rw---- 1 root gpio 254, 1 Mar 22 12:57 /dev/gpiochip1
crw-rw---- 1 root gpio 246, 0 Mar 22 12:57 /dev/gpiomemAs far as I know, access to these should allow access to the gpio. 'members gpio' returns pi, so pi is definitely a member of the gpio group and that group appears to have rw access according to the above output.
-
@jsulm if I run 'ls -l /dev/gp*' I get the following:
crw-rw---- 1 root gpio 254, 0 Mar 22 12:57 /dev/gpiochip0
crw-rw---- 1 root gpio 254, 1 Mar 22 12:57 /dev/gpiochip1
crw-rw---- 1 root gpio 246, 0 Mar 22 12:57 /dev/gpiomemAs far as I know, access to these should allow access to the gpio. 'members gpio' returns pi, so pi is definitely a member of the gpio group and that group appears to have rw access according to the above output.
@Alan-B You definitely can't access gpio without sudo?
-
@jsulm if I run 'ls -l /dev/gp*' I get the following:
crw-rw---- 1 root gpio 254, 0 Mar 22 12:57 /dev/gpiochip0
crw-rw---- 1 root gpio 254, 1 Mar 22 12:57 /dev/gpiochip1
crw-rw---- 1 root gpio 246, 0 Mar 22 12:57 /dev/gpiomemAs far as I know, access to these should allow access to the gpio. 'members gpio' returns pi, so pi is definitely a member of the gpio group and that group appears to have rw access according to the above output.
wrote on 22 Mar 2021, 15:04 last edited by KroMignon@Alan-B said in Debug application as sudo ?:
'members gpio' returns pi, so pi is definitely a member of the gpio group and that group appears to have rw access according to the above output.
With which user did you start your application? Are you sure you are using
pi
account? -
wrote on 22 Mar 2021, 22:16 last edited by
@KroMignon I only have 1 account on the pi so it has to be that one. I am remote debugging from a Linux machine using ssh, connecting using the default 'pi' user account.
-
wrote on 22 Mar 2021, 22:44 last edited by
Finally cracked it!
Not sure if it's the best/easiest way but it works.
- SSH into remote pi and issue this command : sudo gdbserver localhost:10000 appname
- In Creator select Debug | Start Debugging | Attach to Running Debug Server. Enter Server = 10000 and select Local Executable file.
Hit OK and debugging runs as normal but with sudo privileges.
10/10