From 50a3ec5802f221e03beb9757eb005c9d8a958c23 Mon Sep 17 00:00:00 2001 From: Elias Gabrielsson Date: Sun, 14 Jan 2018 21:42:36 +0100 Subject: [PATCH] Added PINE64 support for system binding and gpio closes #310 Signed-off-by: Elias Gabrielsson (github: EliasGabrielsson) --- functions/system.sh | 16 ++++++++++++++++ includes/PINE64-80-gpio-noroot.rules | 7 +++++++ openhabian-setup.sh | 1 + 3 files changed, 24 insertions(+) create mode 100644 includes/PINE64-80-gpio-noroot.rules diff --git a/functions/system.sh b/functions/system.sh index 79cf59205..b8fcb5d5a 100644 --- a/functions/system.sh +++ b/functions/system.sh @@ -162,6 +162,9 @@ permissions_corrections() { echo "FAILED (please execute after openHAB was installed)" exit 1 fi + + if is_pine64; then pine64_gpio_permissions;fi + cond_redirect adduser openhab dialout cond_redirect adduser openhab tty cond_redirect adduser openhab gpio @@ -217,6 +220,19 @@ pine64_platform_scripts() { fi } +pine64_gpio_permissions() { + cond_redirect groupadd gpio + cond_redirect cp $BASEDIR/includes/PINE64-80-gpio-noroot.rules /etc/udev/rules.d/80-gpio-noroot.rules + cond_redirect sed -i -e '$i \chown -R root:gpio /sys/class/gpio \n' /etc/rc.local + cond_redirect sed -i -e '$i \chmod -R ug+rw /sys/class/gpio \n' /etc/rc.local +} + +pine64_fix_system_binding() { # This will maybe be fixed upstreams some day. Keep an eye open. + cond_redirect apt-get install -y udev:armhf + cond_redirect ln -s /lib/arm-linux-gnueabihf/ /lib/linux-arm + cond_redirect ln -s /lib/linux-arm/libudev.so.1 /lib/linux-arm/libudev.so +} + pine64_fixed_mac() { echo -n "$(timestamp) [openHABian] Assigning fixed MAC address to eth0 (longsleep)... " if ! grep -q "mac_addr=" /boot/uEnv.txt; then diff --git a/includes/PINE64-80-gpio-noroot.rules b/includes/PINE64-80-gpio-noroot.rules new file mode 100644 index 000000000..ed7815bbc --- /dev/null +++ b/includes/PINE64-80-gpio-noroot.rules @@ -0,0 +1,7 @@ +# /etc/udev/rules.d/80-gpio-noroot.rules +# Corrects sys GPIO permissions on the Pine64 so non-root users in the gpio group can manipulate bits +# +# Change group to gpio +SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chown -R root:gpio /sys/devices/soc.0/*pinctrl/gpio'" +# Change user permissions to ensure user and group have read/write permissions +SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chmod -R ug+rw /sys/devices/soc.0/*pinctrl/gpio'" \ No newline at end of file diff --git a/openhabian-setup.sh b/openhabian-setup.sh index 606dafe31..ea06fb2f5 100755 --- a/openhabian-setup.sh +++ b/openhabian-setup.sh @@ -60,6 +60,7 @@ if [[ -n "$UNATTENDED" ]]; then if is_pi; then memory_split; enable_rpi_audio; fi if is_pine64; then pine64_platform_scripts; fi if is_pine64; then pine64_fixed_mac; fi + if is_pine64; then pine64_fix_system_binding; fi basic_packages needed_packages bashrc_copy