Installation-gpio
This revision is from 2014/09/01 12:16. You can Restore it.
open
vim /etc/init.d/gpio
and paste
#!/bin/sh ### BEGIN INIT INFO # Provides: gpio # Required-Start: $local_fs $syslog # Required-Stop: $local_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Start gpio ### END INIT INFO # RPI board revision REV=$(cat /sys/module/bcm2708/parameters/boardrev) echo "4" > /sys/class/gpio/export echo "7" > /sys/class/gpio/export echo "8" > /sys/class/gpio/export echo "9" > /sys/class/gpio/export echo "10" > /sys/class/gpio/export echo "11" > /sys/class/gpio/export echo "14" > /sys/class/gpio/export echo "15" > /sys/class/gpio/export echo "17" > /sys/class/gpio/export echo "18" > /sys/class/gpio/export echo "22" > /sys/class/gpio/export echo "23" > /sys/class/gpio/export echo "24" > /sys/class/gpio/export echo "25" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio4/direction echo "out" > /sys/class/gpio/gpio7/direction echo "out" > /sys/class/gpio/gpio8/direction echo "out" > /sys/class/gpio/gpio9/direction echo "out" > /sys/class/gpio/gpio10/direction echo "out" > /sys/class/gpio/gpio11/direction echo "out" > /sys/class/gpio/gpio14/direction echo "out" > /sys/class/gpio/gpio15/direction echo "out" > /sys/class/gpio/gpio17/direction echo "out" > /sys/class/gpio/gpio18/direction echo "out" > /sys/class/gpio/gpio22/direction echo "out" > /sys/class/gpio/gpio23/direction echo "out" > /sys/class/gpio/gpio24/direction echo "out" > /sys/class/gpio/gpio25/direction chmod 666 /sys/class/gpio/gpio4/value chmod 666 /sys/class/gpio/gpio7/value chmod 666 /sys/class/gpio/gpio8/value chmod 666 /sys/class/gpio/gpio9/value chmod 666 /sys/class/gpio/gpio10/value chmod 666 /sys/class/gpio/gpio11/value chmod 666 /sys/class/gpio/gpio14/value chmod 666 /sys/class/gpio/gpio15/value chmod 666 /sys/class/gpio/gpio17/value chmod 666 /sys/class/gpio/gpio18/value chmod 666 /sys/class/gpio/gpio22/value chmod 666 /sys/class/gpio/gpio23/value chmod 666 /sys/class/gpio/gpio24/value chmod 666 /sys/class/gpio/gpio25/value chmod 666 /sys/class/gpio/gpio4/direction chmod 666 /sys/class/gpio/gpio7/direction chmod 666 /sys/class/gpio/gpio8/direction chmod 666 /sys/class/gpio/gpio9/direction chmod 666 /sys/class/gpio/gpio10/direction chmod 666 /sys/class/gpio/gpio11/direction chmod 666 /sys/class/gpio/gpio14/direction chmod 666 /sys/class/gpio/gpio15/direction chmod 666 /sys/class/gpio/gpio17/direction chmod 666 /sys/class/gpio/gpio18/direction chmod 666 /sys/class/gpio/gpio22/direction chmod 666 /sys/class/gpio/gpio23/direction chmod 666 /sys/class/gpio/gpio24/direction chmod 666 /sys/class/gpio/gpio25/direction if [ $REV -lt 4 ]; then #rev 1-3 GPIO 21 echo "21" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio21/direction chmod 666 /sys/class/gpio/gpio21/value chmod 666 /sys/class/gpio/gpio21/direction else #rev 4- GPIO 27 echo "27" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio27/direction chmod 666 /sys/class/gpio/gpio27/value chmod 666 /sys/class/gpio/gpio27/direction fi if [ $REV -gt 15 ]; then #rev 16- (model B+) echo "5" > /sys/class/gpio/export echo "6" > /sys/class/gpio/export echo "12" > /sys/class/gpio/export echo "13" > /sys/class/gpio/export echo "16" > /sys/class/gpio/export echo "19" > /sys/class/gpio/export echo "20" > /sys/class/gpio/export echo "21" > /sys/class/gpio/export echo "26" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio5/direction echo "out" > /sys/class/gpio/gpio6/direction echo "out" > /sys/class/gpio/gpio12/direction echo "out" > /sys/class/gpio/gpio13/direction echo "out" > /sys/class/gpio/gpio16/direction echo "out" > /sys/class/gpio/gpio19/direction echo "out" > /sys/class/gpio/gpio20/direction echo "out" > /sys/class/gpio/gpio21/direction echo "out" > /sys/class/gpio/gpio26/direction chmod 666 /sys/class/gpio/gpio5/value chmod 666 /sys/class/gpio/gpio6/value chmod 666 /sys/class/gpio/gpio12/value chmod 666 /sys/class/gpio/gpio13/value chmod 666 /sys/class/gpio/gpio16/value chmod 666 /sys/class/gpio/gpio19/value chmod 666 /sys/class/gpio/gpio20/value chmod 666 /sys/class/gpio/gpio21/value chmod 666 /sys/class/gpio/gpio26/value chmod 666 /sys/class/gpio/gpio5/direction chmod 666 /sys/class/gpio/gpio6/direction chmod 666 /sys/class/gpio/gpio12/direction chmod 666 /sys/class/gpio/gpio13/direction chmod 666 /sys/class/gpio/gpio16/direction chmod 666 /sys/class/gpio/gpio19/direction chmod 666 /sys/class/gpio/gpio20/direction chmod 666 /sys/class/gpio/gpio21/direction chmod 666 /sys/class/gpio/gpio26/direction fi DIR=$(cat /etc/remoteqth-path) # Restore the current gpio settings SAVE=$(cat $DIR/cfg/s-relay-save) if [ $SAVE -eq 1 ]; then # echo SAVE if [ $REV -lt 16 ]; then NRGPIO='15' else # model B+ NRGPIO='24' fi for NR in `seq 1 $NRGPIO`; do if [ -r $DIR/cfg/s-relay-$NR-save ]; then SET=$(cat $DIR/cfg/s-relay-$NR-save) if [ -w $DIR/cfg/gpio$NR ]; then echo $SET > $DIR/cfg/gpio$NR fi fi done fi exit 0
enabled with
chmod 774 /etc/init.d/gpio update-rc.d gpio defaults