mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
Requirement for reboot removed from SPI and I2C settings.
This commit is contained in:
parent
806bfa79fe
commit
073e5620cf
169
raspi-config
169
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user