1

I developed some code using wiringpi on a 4.4.21 machine (Jessie) - it worked fine and as expected, required root privilege to run (i.e. requires sudo) - it uses wiringPiSetup().

I moved the code over to a 4.9.59 (Stretch) machine and re-compiled - but when run it doesn't require root privilege (i.e. sudo not needed). Both are being initiated by the "pi" user. The Jessie machine is V1.2 pi zero (no camera connector). The Stretch machine is a V1.3 pi zero (with camera connector - but not a W).

The only other difference I've noted is that during compiling/linking on Stretch it required the inclusion of unistd.h for the use of sleep() which it didn't seem to need on Jessie (least ways cc didn't complain).

Why is root not required on Stretch, but it is on Jessie? I did not expect this to be the case.

  • 1
    What exactly is your question? – Steve Robillard Feb 22 '18 at 21:45
  • Well why? its not expected behaviour in the Stretch case. – Steve R Feb 22 '18 at 22:14
  • 1
    That detail belongs in your question, not the comments. – Steve Robillard Feb 23 '18 at 4:30
3

wiringPi was modified to allow the use of /dev/gpiomem rather than /dev/mem to access the GPIO.

To access the GPIO via /dev/mem requires root privileges.

By default /dev/gpiomem can be accessed by members of group gpio. The default pi user is a member of group gpio. This means the default pi user can use wiringPi to access the GPIO without being root.

This only affects usage of the GPIO. For instance wiringPi hardware PWM requires access to the PWM peripheral. For this you still need to run as root.

  • Great - that must be the answer - I must have an old version of wiring pi on the Jessie machine. Thanks - I don't like unexplained behavior as it often indicative of other problems. – Steve R Feb 22 '18 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.