diff --git a/raspi-config b/raspi-config index 1175c4f1..343d69db 100755 --- a/raspi-config +++ b/raspi-config @@ -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 @@ -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 @@ -369,14 +378,36 @@ 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 @@ -384,12 +415,21 @@ do 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 @@ -397,12 +437,20 @@ if [ $(id -u) -ne 0 ]; then 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 #