Installation-gpio
This revision is from 2015/03/22 00:32. 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=$(grep Revision /proc/cpuinfo | cut -d ':' -f2 | sed 's/ //g') #0002 - Model B Revision 1.0 256MB #0003 - Model B Revision 1.0 + ECN0001 (no fuses, D14 removed) 256MB #0004-6 - Model B Revision 2.0Mounting holes 256MB #0007-9 - Model A Mounting holes 256MB #000d-f - Model B Revision 2.0 Mounting holes 512MB #0010 - Model B+ 512MB #0011 - Compute Module 512MB #0012 - Model A+ 256MB #a01041|a21041 - Pi 2 Model B 1GB 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 if [ $REV = '0002' ] || [ $REV = '0003' ]; then # GPIO 21/27 set 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+) if [ $REV = '0010' ] || [ $REV = '0012' ] || [ $REV = 'a01041' ] || [ $REV = 'a21041' ]; then # 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 = '0010' ] || [ $REV = '0012' ] || [ $REV = 'a01041' ] || [ $REV = 'a21041' ]; then # model B+ NRGPIO='24' else NRGPIO='15' 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