Skip to content

Commit

Permalink
Added PINE64 support for system binding and gpio closes #310
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Gabrielsson <[email protected]> (github: EliasGabrielsson)
  • Loading branch information
EliasGabrielsson committed Jan 24, 2018
1 parent c2b505e commit 50a3ec5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions functions/system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions includes/PINE64-80-gpio-noroot.rules
Original file line number Diff line number Diff line change
@@ -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'"
1 change: 1 addition & 0 deletions openhabian-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50a3ec5

Please sign in to comment.