How to handle “Unable to open /dev/mem: Operation not permitted”

In case you have kernel 4.9.4+ and you might need to use GPIO fucntions, sudenly you’ll receive an error message like the one described below:

wiringPiSetup: Unable to open /dev/mem: Operation not permitted

This is a kernel issue solved in later updates of this kernel version.

In order to solve the problem you have two possibilities:

  1. Make a firmware update and versons later than 4.9.73+ solve this issue
  2. Keep you kernel and firmware but add iomem=relaxed to /boot/cmdline.txt

Leave a Reply