Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. Debug application as sudo ?

Debug application as sudo ?

Scheduled Pinned Locked Moved Solved QtonPi
10 Posts 4 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan B
    wrote on 22 Mar 2021, 08:59 last edited by Alan B
    #1

    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?

    J J 2 Replies Last reply 22 Mar 2021, 09:03
    0
    • A Alan B
      22 Mar 2021, 08:59

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 22 Mar 2021, 09:03 last edited by
      #2

      @Alan-B Did you try to start debugger with sudo?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Alan B
        22 Mar 2021, 08:59

        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?

        J Offline
        J Offline
        JonB
        wrote on 22 Mar 2021, 09:28 last edited by
        #3

        @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?

        1 Reply Last reply
        1
        • A Offline
          A Offline
          Alan B
          wrote on 22 Mar 2021, 13:03 last edited by
          #4

          @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.

          J 1 Reply Last reply 22 Mar 2021, 13:20
          0
          • A Alan B
            22 Mar 2021, 13:03

            @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.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 22 Mar 2021, 13:20 last edited by
            #5

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Alan B
              wrote on 22 Mar 2021, 14:48 last edited by
              #6

              @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/gpiomem

              As 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.

              J K 2 Replies Last reply 22 Mar 2021, 14:52
              0
              • A Alan B
                22 Mar 2021, 14:48

                @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/gpiomem

                As 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.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 22 Mar 2021, 14:52 last edited by
                #7

                @Alan-B You definitely can't access gpio without sudo?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • A Alan B
                  22 Mar 2021, 14:48

                  @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/gpiomem

                  As 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.

                  K Offline
                  K Offline
                  KroMignon
                  wrote on 22 Mar 2021, 15:04 last edited by KroMignon
                  #8

                  @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?

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Alan B
                    wrote on 22 Mar 2021, 22:16 last edited by
                    #9

                    @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.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Alan B
                      wrote on 22 Mar 2021, 22:44 last edited by
                      #10

                      Finally cracked it!

                      Not sure if it's the best/easiest way but it works.

                      1. SSH into remote pi and issue this command : sudo gdbserver localhost:10000 appname
                      2. 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.

                      1 Reply Last reply
                      0

                      10/10

                      22 Mar 2021, 22:44

                      • Login

                      • Login or register to search.
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved