Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable command line options again #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 65 additions & 17 deletions raspi-config
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,13 @@ do_memory_split() {
if ! mountpoint -q /boot; then
return 1
fi
## get current memory split from /boot/config.txt
CUR_GPU_MEM=$(get_config_var gpu_mem /boot/config.txt)
[ -z "$CUR_GPU_MEM" ] && CUR_GPU_MEM=64
## get current memory split
get_current_gpu_mem
## ask users what gpu_mem they want
NEW_GPU_MEM=$(whiptail --inputbox "How much memory should the GPU have? e.g. 16/32/64/128/256" \
20 70 -- "$CUR_GPU_MEM" 3>&1 1>&2 2>&3)
20 70 -- "$CURRENT_GPU_MEM" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
set_config_var gpu_mem "$NEW_GPU_MEM" /boot/config.txt
set_gpu_mem ${NEW_GPU_MEM}
ASK_TO_REBOOT=1
fi
else # Old firmware so do start.elf renaming
Expand Down Expand Up @@ -207,6 +206,16 @@ set_memory_split() {
sync
}

get_current_gpu_mem() {
## get current memory split from /boot/config.txt
CURRENT_GPU_MEM=$(get_config_var gpu_mem /boot/config.txt)
[ -z "$CURRENT_GPU_MEM" ] && CURRENT_GPU_MEM=64
}

set_gpu_mem() {
set_config_var gpu_mem "${1}" /boot/config.txt
}

do_overclock() {
whiptail --msgbox "\
Be aware that overclocking may reduce the lifetime of your
Expand Down Expand Up @@ -369,40 +378,79 @@ for i in $*
do
case $i in
--memory-split)
OPT_MEMORY_SPLIT=GET
printf "Not currently supported\n"
exit 1
if [ -e /boot/start_cd.elf ]; then
echo "This system sets the gpu memory instead of the split. Try --gpu_mem instead."
exit 1
else
OPT_MEMORY_SPLIT=GET
fi
;;
--memory-split=*)
OPT_MEMORY_SPLIT=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
printf "Not currently supported\n"
exit 1
if [ -e /boot/start_cd.elf ]; then
echo "This system sets the gpu memory instead of the split. Try --gpu_mem instead."
exit 1
else
OPT_MEMORY_SPLIT=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
fi
;;
--gpu_mem)
if [ ! -e /boot/start_cd.elf ]; then
echo "This system sets the memory split by changing start.elf. Try --memory-split instead."
exit 1
else
OPT_GPU_MEM=GET
fi
;;
--gpu_mem=*)
if [ ! -e /boot/start_cd.elf ]; then
echo "This system sets the memory split by changing start.elf. Try --memory-split instead."
exit 1
else
OPT_GPU_MEM=`echo $i | sed 's/[-_a-zA-Z0-9]*=//'`
fi
;;
*)
# unknown option
;;
esac
done

#if [ "GET" = "${OPT_MEMORY_SPLIT:-}" ]; then
# set -u # Fail on unset variables
# get_current_memory_split
# echo $CURRENT_MEMSPLIT
# exit 0
#fi
# Old style memory split getting
if [ "GET" = "${OPT_MEMORY_SPLIT:-}" ]; then
set -u # Fail on unset variables
get_current_memory_split
echo $CURRENT_MEMSPLIT
exit 0
fi

# Get the GPU memory
if [ "GET" = "${OPT_GPU_MEM:-}" ]; then
set -u # Fail on unset variables
get_current_gpu_mem
echo $CURRENT_GPU_MEM
exit 0
fi

# Everything else needs to be run as root
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo raspi-config'\n"
exit 1
fi

# Old style memory split setting
if [ -n "${OPT_MEMORY_SPLIT:-}" ]; then
set -e # Fail when a command errors
set_memory_split "${OPT_MEMORY_SPLIT}"
exit 0
fi

# Set the gpu memory
if [ -n "${OPT_GPU_MEM:-}" ]; then
set -e # Fail when a command errors
set_gpu_mem "${OPT_GPU_MEM}"
exit 0
fi

#
# Interactive use loop
#
Expand Down