picberry icon indicating copy to clipboard operation
picberry copied to clipboard

Change use of /dev/mem to /dev/gpiomem

Open MikeDK opened this issue 1 year ago • 4 comments

If we use /dev/gpiomem instead of /dev/mem, we have some benefits...:

  • /dev/gpiomem can be accessed by users of group "gpio" - so no root access required any more!
  • the GPIO_BASE macro is not needed any more ... so theoretically we would not need any difference between raspberry pi 1, 2 and 4 - they could use one single .h file and only one build target is needed for raspberries
  • in 64bit kernels there is a kernel config option which prohibits userspace access to /dev/mem ... this is enabled in nearly every recent OS, so one would have to pass kernel options to disable this behaviour .... but because we use gpiomem now, this is not needed!

Compiling for all build configs, but I have only tested the raspberrypi4 one

MikeDK avatar Nov 18 '24 14:11 MikeDK

added another commit which removes the unnecessary build configs and .h files ... there is now only one "raspberrypi" build target

MikeDK avatar Nov 18 '24 15:11 MikeDK

This is not universally supported, not all host boards have a gpiomem driver. So at the very least this change should be optional behind a flag, not changed outright.

Grix avatar Nov 20 '24 13:11 Grix

Ok you're right ... I will add a flag to the raspberrypi.h file and restore the stuff to the a10 and am335x

MikeDK avatar Nov 20 '24 13:11 MikeDK

done adding a flag for /dev/gpiomem usage

MikeDK avatar Nov 20 '24 15:11 MikeDK