davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

wiringPi 2.32: error: wiringPi must be root ???

Sat May 14, 2016 4:46 pm

hi,
although I have updated to wiringPi 2.32, I get the error msg "wiringPi must be root" when I try starting my program by Geany (F5) -
how can that be ?
Shouldn't this issue have been fixed meanwhile ?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: wiringPi 2.32: error: wiringPi must be root ???

Sat May 14, 2016 6:59 pm

davenull wrote:hi,
although I have updated to wiringPi 2.32, I get the error msg "wiringPi must be root" when I try starting my program by Geany (F5) -
how can that be ?
Shouldn't this issue have been fixed meanwhile ?
What issue?

There is no issue here. Use sudo to run your program or read the documentation on running as non-root.

-Gordon
--
Gordons projects: https://projects.drogon.net/

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: wiringPi 2.32: error: wiringPi must be root ???

Sat May 14, 2016 7:03 pm

I could not find anything I was able to understand how to not have to run it by sudo.
And I'm not the only one who is puzzled
http://www.roboternetz.de/community/thr ... post626784
- who needs sudo, and why is non-sudo not the default?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
rpdom
Posts: 17030
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: wiringPi 2.32: error: wiringPi must be root ???

Sat May 14, 2016 7:12 pm

For a long time now, the sudo method has been the only way to access the GPIOs.

Now there is an alternative.

Most libraries have switched to using the new method for most things, but the WP one still defaults to the way that needs sudo. IIRC you need to set a shell variable or parameter to get it to use the non-sudo method. I can't remember what it was though.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: wiringPi 2.32: error: wiringPi must be root ???

Sat May 14, 2016 7:13 pm

davenull wrote:I could not find anything I was able to understand how to not have to run it by sudo.
And I'm not the only one who is puzzled
http://www.roboternetz.de/community/thr ... post626784
- who needs sudo, and why is non-sudo not the default?
Without sudo you can not use PWM, nor can you control the internal pull-up/down resistors. (This may have changed, but no-ones told me)

To make wiringPi use non-root access you need to set the enviroment variable. Extract from the gpio program man page:

Code: Select all

       As of kernels 4.1.7, a user-level GPIO access mechanism  is  available,
       however  wiringPi  will  not use this by default - because at this time
       there appears to be issues when trying to program the PWM or clock out‐
       put  hardware.  If you can live without PWM or GPIO clocks and you want
       to use the GPIO from a non-root program, then you  need  to  make  sure
       that  the  module  bcm2835_gpiomem  is loaded at boot time. This should
       happen automatically when you enable the device tree  in  raspi-config.
       You  may also need some additional information in /etc/udev/rules.d/ to
       change the mode and ownership of the /dev/gpiomem  file.  Finally,  you
       need  to  set  the environment variable WIRINGPI_GPIOMEM. This will go-
       away in future releases once the /dev/gpiomem interface is fully opera‐
       tional.
Also make sure that the output of

Code: Select all

gpio -v
actually says that user mode GPIO is avalable.

e.g.

Code: Select all

gpio version: 2.34
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Model B, Revision: 02, Memory: 512MB, Maker: Sony 
  * Device tree is enabled.
  * This Raspberry Pi supports user-level GPIO access.
    -> See the man-page for more details
    -> ie. export WIRINGPI_GPIOMEM=1
-Gordon
--
Gordons projects: https://projects.drogon.net/

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: wiringPi 2.32: error: wiringPi must be root ???

Sat May 14, 2016 7:14 pm

Without sudo you can not use PWM, nor can you control the internal pull-up/down resistors.
ok, as I always need all that, that's reason enough, thank you!

Anyway, I still don't understand the procedure to disable sudo in case I wanted, it's really extremely complicated and confusing...
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:24 am

davenull wrote:
Without sudo you can not use PWM, nor can you control the internal pull-up/down resistors.
ok, as I always need all that, that's reason enough, thank you!

Anyway, I still don't understand the procedure to disable sudo in case I wanted, it's really extremely complicated and confusing...
Maybe you should stop programming and take some time to learn more about the environment you're programming in. Environment variables are only about 40 years old in the Unix world.

-Gordon
--
Gordons projects: https://projects.drogon.net/

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:36 am

well, I know what environmet variables are, I used them by DOS since 30 years and Windows since 20 years.
I simply don't understand your plan what exact to do, not in a prosaic style but in a short to-do-list :

1. ?
2. ?
3. ?
4. ?
5. ?
...?

maybe one could wrap that into a bash file, to be started manually in case of wish or need.

Not for me just in that moment right now, compellingly, but just because of general reasons, and because many (i.e., especially non-native English speakers) don't understand what to do
- but anyway, IMO it would be finally even more better if one could abandon all that cryptic command and adjustment stuff in the moment when one was eventually able to use GPIO pullups and pwm as a standard user at either time.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
joan
Posts: 14888
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:40 am

gordon@drogon.net wrote:
davenull wrote:
Without sudo you can not use PWM, nor can you control the internal pull-up/down resistors.
ok, as I always need all that, that's reason enough, thank you!

Anyway, I still don't understand the procedure to disable sudo in case I wanted, it's really extremely complicated and confusing...
Maybe you should stop programming and take some time to learn more about the environment you're programming in. Environment variables are only about 40 years old in the Unix world.

-Gordon
As far as I am aware you can control the PUD via /dev/gpiomem, their registers are in the same memory block.

I reckon the OP is talking about software PWM rather than hardware PWM so using WIRINGPI_GPIOMEM might well be appropriate.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:41 am

I reckon the OP is talking about software PWM rather than hardware PWM
yes, I use software pwm, but also internal Pullups/downs by the wiringPi libs.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:45 am

davenull wrote:well, I know what environmet variables are, I used them by DOS since 30 years and Windows since 20 years.
I simply don't understand your plan what exact to do, not in a prosaic style but in a short to-do-list :

1. ?
2. ?
3. ?
4. ?
5. ?
...?

maybe one could wrap that into a bash file, to be started manually in case of wish or need.

Not for me just in that moment right now, compellingly, but just because of general reasons, and because many (i.e., especially non-native English speakers) don't understand what to do
- but anyway, IMO it would be finally even more better if one could abandon all that cryptic command and adjustment stuff in the moment when one was eventually able to use GPIO pullups and pwm as a standard user at either time.
0. #include <stdlib.h>
1. main () ... {
2. putenv ("WIRINGPI_GPIOMEM=1") ;
3. wiringPiSetup () ;
4. ...

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:47 am

joan wrote: As far as I am aware you can control the PUD via /dev/gpiomem, their registers are in the same memory block.
Yes, you're right. It's been a while...

-Gordon
--
Gordons projects: https://projects.drogon.net/

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:51 am

aaahh... not in the terminal, but in the program itself...?!
I faultily assumed one had to do things like
beware, faulty assumes! wrote:
cat /etc/group
sudo usermod -aG gpio pi
sudo usermod -aG dialout pi
ok, that would be fine if one could read that in your user manual, as not everyone would be supposed to find this.topic to read for clarification... 8-)

Code: Select all

0. #include <stdlib.h>
1. main () ... {
2. putenv ("WIRINGPI_GPIOMEM=1") ;
3. wiringPiSetup () ;
4. ...
But thank you, I'll forward your post to the original questioner in a different forum! (edited, typo)
Last edited by davenull on Sun May 15, 2016 9:56 am, edited 1 time in total.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:54 am

davenull wrote:
But thank you, I'll forward your post to the original questioner in a dirrent forum!
And remind them that I only read this forum occasionally as lifes too short to read the world, so if they want support then they should use email...

-Gordon
--
Gordons projects: https://projects.drogon.net/

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:56 am

yes, I'll do! :)
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
joan
Posts: 14888
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: wiringPi 2.32: error: wiringPi must be root ???

Sun May 15, 2016 9:57 am

gordon@drogon.net wrote: ...
It's been a while...
...
Probably the pads rather than the puds.

Return to “C/C++”