mirror of
https://github.com/brain-hackers/brain-config.git
synced 2025-01-01 00:50: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
|
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() {
|
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
|
CURRENT_SETTING="off" # assume disabled
|
||||||
DEFAULT=--defaultno
|
DEFAULT=--defaultno
|
||||||
if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then
|
if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*spi(=(on|true|yes|1))?(,.*)?$" $CONFIG; then
|
||||||
@ -561,63 +518,35 @@ do_spi() {
|
|||||||
DEFAULT=
|
DEFAULT=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $DEVICE_TREE = "yes" ]; then
|
if [ "$INTERACTIVE" = True ]; then
|
||||||
if [ "$INTERACTIVE" = True ]; then
|
whiptail --yesno "Would you like the SPI interface to be enabled?" $DEFAULT 20 60 2
|
||||||
whiptail --yesno "Would you like the SPI interface to be enabled?" $DEFAULT 20 60 2
|
RET=$?
|
||||||
RET=$?
|
else
|
||||||
else
|
RET=$1
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
if [ $RET -eq 0 ]; then
|
||||||
CURRENT_STATUS="yes" # assume not blacklisted
|
SETTING=on
|
||||||
DEFAULT=
|
STATUS=enabled
|
||||||
if [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*spi[-_]bcm2708" $BLACKLIST; then
|
elif [ $RET -eq 1 ]; then
|
||||||
CURRENT_STATUS="no"
|
SETTING=off
|
||||||
DEFAULT=--defaultno
|
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
|
fi
|
||||||
|
|
||||||
if ! [ -e $BLACKLIST ]; then
|
if ! [ -e $BLACKLIST ]; then
|
||||||
touch $BLACKLIST
|
touch $BLACKLIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*spi[-_]bcm2708\)/#\1/"
|
sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*spi[-_]bcm2708\)/#\1/"
|
||||||
dtparam spi=on
|
|
||||||
|
dtparam spi=$SETTING
|
||||||
}
|
}
|
||||||
|
|
||||||
do_i2c() {
|
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
|
CURRENT_SETTING="off" # assume disabled
|
||||||
DEFAULT=--defaultno
|
DEFAULT=--defaultno
|
||||||
if [ -e $CONFIG ] && grep -q -E "^(device_tree_param|dtparam)=([^,]*,)*i2c(_arm)?(=(on|true|yes|1))?(,.*)?$" $CONFIG; then
|
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=
|
DEFAULT=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $DEVICE_TREE = "yes" ]; then
|
if [ "$INTERACTIVE" = True ]; then
|
||||||
if [ "$INTERACTIVE" = True ]; then
|
whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2
|
||||||
whiptail --yesno "Would you like the ARM I2C interface to be enabled?" $DEFAULT 20 60 2
|
RET=$?
|
||||||
RET=$?
|
else
|
||||||
else
|
RET=$1
|
||||||
RET=$1
|
fi
|
||||||
fi
|
if [ $RET -eq 0 ]; then
|
||||||
if [ $RET -eq 0 ]; then
|
SETTING=on
|
||||||
SETTING=on
|
STATUS=enabled
|
||||||
STATUS=enabled
|
elif [ $RET -eq 1 ]; then
|
||||||
elif [ $RET -eq 1 ]; then
|
SETTING=off
|
||||||
SETTING=off
|
STATUS=disabled
|
||||||
STATUS=disabled
|
else
|
||||||
else
|
return 0
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURRENT_STATUS="yes" # assume not blacklisted
|
set_config_var dtparam=i2c_arm $SETTING $CONFIG &&
|
||||||
DEFAULT=
|
if [ "$INTERACTIVE" = True ]; then
|
||||||
if [ -e $BLACKLIST ] && grep -q "^blacklist[[:space:]]*i2c[-_]bcm2708" $BLACKLIST; then
|
whiptail --msgbox "The ARM I2C interface is $STATUS" 20 60 1
|
||||||
CURRENT_STATUS="no"
|
|
||||||
DEFAULT=--defaultno
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -e $BLACKLIST ]; then
|
if ! [ -e $BLACKLIST ]; then
|
||||||
touch $BLACKLIST
|
touch $BLACKLIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
|
sed $BLACKLIST -i -e "s/^\(blacklist[[:space:]]*i2c[-_]bcm2708\)/#\1/"
|
||||||
|
|
||||||
sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/"
|
sed /etc/modules -i -e "s/^#[[:space:]]*\(i2c[-_]dev\)/\1/"
|
||||||
if ! grep -q "^i2c[-_]dev" /etc/modules; then
|
if ! grep -q "^i2c[-_]dev" /etc/modules; then
|
||||||
printf "i2c-dev\n" >> /etc/modules
|
printf "i2c-dev\n" >> /etc/modules
|
||||||
fi
|
fi
|
||||||
dtparam i2c_arm=on
|
|
||||||
|
dtparam i2c_arm=$SETTING
|
||||||
modprobe i2c-dev
|
modprobe i2c-dev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user