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 ?
QtWS25 Last Chance

Debug application as sudo ?

Scheduled Pinned Locked Moved Solved QtonPi
10 Posts 4 Posters 2.1k 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 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?

    jsulmJ JonBJ 2 Replies Last reply
    0
    • A 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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

        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?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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 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.

          jsulmJ 1 Reply Last reply
          0
          • A Alan B

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

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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 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.

              jsulmJ KroMignonK 2 Replies Last reply
              0
              • A Alan B

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

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on 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

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

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on 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 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 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

                      • Login

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