wiringPi update to 2.29

Two main things in this release are an updates max31855 thermocouple driver and the ability to use the new /dev/gpiomem interface which can be used from a user-level program without the need to be root or use sudo.

To use the new /dev/gpiomem interface you need to be running a 4.1.7 or greater kernel with the device tree enabled and have the bcm2835_gpiomem kernel module loaded. This should load automatically. However in addition to that, you’ll also need some udev rules that do not appear to be present in the current releases. My suggestion for now is to copy this into /etc/udev/rules.d/20-gpio.rules:

SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"

then reboot (easiest), or restart udev then remove and modprobe the kernel module.

Even after doing that, access to /dev/gpiomem is not enabled by default in wiringPi and the reason for this is that using it to try to access the PWM or clock hardware registers will cause your Pi to crash requiring a power cycle.

To enable it in your programs you need to set the environment variable WIRINGPI_GPIOMEM. You can do this by typing:

export WIRINGPI_GPIOMEM=1

at the bash prompt, or if you’re using csh/tcsh, etc. then

setenv WIRINGPI_GPIOMEM 1

If you try to use the PWM or clock devices via the /dev/gpiomem interface then the calls will be ignored.

Update wiringPi by the usual way:

cd ~/wiringPi
git pull
./build

however a .deb package will be available soon.

Comments are closed.