I have been scouring the web for a few hours now and I cannot seem to fix the problem. I am using RPi 4B 8GB RAM with Ubuntu 22.04 server.

When trying to run C++ code with wiringPi to activate PWM I get this error

pinMode PWM: Unable to do this when using /dev/gpiomem. Try sudo?

I am running my executable through ROS2 and hence cannot give it root privileges. I have already tried:

  • sudo adduser pi gpio
  • sudo usermod -a -G gpio $USER
  • sudo chown root.gpio /dev/gpiomem
  • sudo chmod g+rw /dev/gpiomem

and none will do.

Also the output of my ls -l is

crw-rw---- 1 root dialout 506, 0 Feb 19 21:48 /dev/gpiomem


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.