I've compiled application on Linux, but I got this error

wiringPiSetup: mmap (GPIO) failed: Operation not permitted

After that:

I've added iomem=relaxed to grub

 cat /proc/cmdline 

 root=UUID=da37e191-361e-4343-a63b-980e2696c8d6 ro iomem=relaxed
 console=tty1 console=ttyS0

But It didn't help. How I can fix this issue?


lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic
  • 2
    that wiringPi library tries to mmap /dev/mem, and only root can do that.
    – mosvy
    Feb 25 '20 at 11:18
  • I always run command under root.
    – unknown
    Feb 25 '20 at 15:20
  • true </dev/mem Works fine. 28485 openat(AT_FDCWD, "/dev/mem", O_RDWR|O_SYNC|O_CLOEXEC) = 3 28485 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, x3f200000) = -1 EPERM (Operation not permitted) 28485 write(2, "wiringPiSetup: mmap (GPIO) faile"..., 59) = 59 - Output from strace log.
    – unknown
    Feb 26 '20 at 9:11
  • That should be something related to Ubuntu; I'll add the tag, maybe someone who's running Ubuntu on the RaspberryPi can shed some light on this.
    – mosvy
    Feb 27 '20 at 8:22

Your Answer

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

Browse other questions tagged or ask your own question.