From 073e5620cf5176f60d99f43bfaabe313c3b8fada Mon Sep 17 00:00:00 2001 From: spl Date: Thu, 19 May 2016 15:11:12 +0100 Subject: [PATCH] Requirement for reboot removed from SPI and I2C settings. --- raspi-config | 169 ++++++++++++--------------------------------------- 1 file changed, 39 insertions(+), 130 deletions(-) diff --git a/raspi-config b/raspi-config index cb4d73a..1ae5ca2 100755 --- a/raspi-config +++ b/raspi-config @@ -510,50 +510,7 @@ do_ssh() { fi } -do_devicetree() { - CURRENT_SETTING="enabled" # assume not disabled - DEFAULT= - if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then - CURRENT_SETTING="disabled" - DEFAULT=--defaultno - fi - if [ "$INTERACTIVE" = True ]; then - whiptail --yesno "Would you like the kernel to use Device Tree?" $DEFAULT 20 60 2 - RET=$? - else - RET=$1 - fi - if [ $RET -eq 0 ]; then - sed $CONFIG -i -e "s/^\(device_tree=\)$/#\1/" - sed $CONFIG -i -e "s/^#\(device_tree=.\)/\1/" - SETTING=enabled - elif [ $RET -eq 1 ]; then - sed $CONFIG -i -e "s/^#\(device_tree=\)$/\1/" - sed $CONFIG -i -e "s/^\(device_tree=.\)/#\1/" - if ! grep -q "^device_tree=$" $CONFIG; then - printf "device_tree=\n" >> $CONFIG - fi - SETTING=disabled - else - return 0 - fi - TENSE=is - REBOOT= - if [ $SETTING != $CURRENT_SETTING ]; then - TENSE="will be" - REBOOT=" after a reboot" - ASK_TO_REBOOT=1 - fi - whiptail --msgbox "Device Tree $TENSE $SETTING$REBOOT" 20 60 1 -} - do_spi() { - DEVICE_TREE="yes" # assume not disabled - DEFAULT= - if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then - DEVICE_TREE="no" - fi - CURRENT_SETTING="off" # assume disabled DEFAULT=--defaultno if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then @@ -561,63 +518,35 @@ do_spi() { DEFAULT= fi - if [ $DEVICE_TREE = "yes" ]; then - if [ "$INTERACTIVE" = True ]; then - whiptail --yesno "Would you like the SPI interface to be enabled?" $DEFAULT 20 60 2 - RET=$? - else - RET=$1 - fi - if [ $RET -eq 0 ]; then - SETTING=on - STATUS=enabled - elif [ $RET -eq 1 ]; then - SETTING=off - STATUS=disabled - else - return 0 - fi - TENSE=is - REBOOT= - if [ $SETTING != $CURRENT_SETTING ]; then - TENSE="will be" - REBOOT=" after a reboot" - ASK_TO_REBOOT=1 - fi - sed $CONFIG -i -r -e "s/^((device_tree_param|dtparam)=([^,]*,)*spi)(=[^,]*)?/\1=$SETTING/" - if ! grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi=[^,]*" $CONFIG; then - printf "dtparam=spi=$SETTING\n" >> $CONFIG - fi - if [ "$INTERACTIVE" = True ]; then - whiptail --msgbox "The SPI interface $TENSE $STATUS$REBOOT" 20 60 1 - fi - if [ $SETTING = "off" ]; then - return 0 - fi + if [ "$INTERACTIVE" = True ]; then + whiptail --yesno "Would you like the SPI interface to be enabled?" $DEFAULT 20 60 2 + RET=$? + else + RET=$1 fi - - CURRENT_STATUS="yes" # assume not blacklisted - DEFAULT= - if [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*spi[-_]bcm2708" $BLACKLIST; then - CURRENT_STATUS="no" - DEFAULT=--defaultno + if [ $RET -eq 0 ]; then + SETTING=on + STATUS=enabled + elif [ $RET -eq 1 ]; then + SETTING=off + STATUS=disabled + else + return 0 + fi + set_config_var dtparam=spi $SETTING $CONFIG && + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "The SPI interface is $STATUS" 20 60 1 fi if ! [ -e $BLACKLIST ]; then touch $BLACKLIST fi - sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*spi[-_]bcm2708\)/#\1/" - dtparam spi=on + + dtparam spi=$SETTING } do_i2c() { - DEVICE_TREE="yes" # assume not disabled - DEFAULT= - if [ -e $CONFIG ] && grep -q "^device_tree=$" $CONFIG; then - DEVICE_TREE="no" - fi - CURRENT_SETTING="off" # assume disabled DEFAULT=--defaultno if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then @@ -625,58 +554,38 @@ do_i2c() { DEFAULT= fi - if [ $DEVICE_TREE = "yes" ]; then - if [ "$INTERACTIVE" = True ]; then - whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2 - RET=$? - else - RET=$1 - fi - if [ $RET -eq 0 ]; then - SETTING=on - STATUS=enabled - elif [ $RET -eq 1 ]; then - SETTING=off - STATUS=disabled - else - return 0 - fi - TENSE=is - REBOOT= - if [ $SETTING != $CURRENT_SETTING ]; then - TENSE="will be" - REBOOT=" after a reboot" - ASK_TO_REBOOT=1 - fi - sed $CONFIG -i -r -e "s/^((device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?)(=[^,]*)?/\1=$SETTING/" - if ! grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?=[^,]*" $CONFIG; then - printf "dtparam=i2c_arm=$SETTING\n" >> $CONFIG - fi - if [ "$INTERACTIVE" = True ]; then - whiptail --msgbox "The ARM I2C interface $TENSE $STATUS$REBOOT" 20 60 1 - fi - if [ $SETTING = "off" ]; then - return 0 - fi + if [ "$INTERACTIVE" = True ]; then + whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2 + RET=$? + else + RET=$1 + fi + if [ $RET -eq 0 ]; then + SETTING=on + STATUS=enabled + elif [ $RET -eq 1 ]; then + SETTING=off + STATUS=disabled + else + return 0 fi - CURRENT_STATUS="yes" # assume not blacklisted - DEFAULT= - if [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*i2c[-_]bcm2708" $BLACKLIST; then - CURRENT_STATUS="no" - DEFAULT=--defaultno + set_config_var dtparam=i2c_arm $SETTING $CONFIG && + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "The ARM I2C interface is $STATUS" 20 60 1 fi if ! [ -e $BLACKLIST ]; then touch $BLACKLIST fi - sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/" + sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/" if ! grep -q "^i2c[-_]dev" /etc/modules; then printf "i2c-dev\n" >> /etc/modules fi - dtparam i2c_arm=on + + dtparam i2c_arm=$SETTING modprobe i2c-dev }