mirror of
https://github.com/brain-hackers/brain-config.git
synced 2025-01-03 18:10:07 +09:00
support new gpu_mem config.txt option for setting memory split
This commit is contained in:
parent
ef2fc242f0
commit
d65377afc7
32
raspi-config
32
raspi-config
@ -91,6 +91,21 @@ EOF
|
|||||||
mv "$3.bak" "$3"
|
mv "$3.bak" "$3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_config_var() {
|
||||||
|
lua - "$1" "$2" <<EOF
|
||||||
|
local key=assert(arg[1])
|
||||||
|
local fn=assert(arg[2])
|
||||||
|
local file=assert(io.open(fn))
|
||||||
|
for line in file:lines() do
|
||||||
|
local val = line:match("^#?%s*"..key.."=(.*)$")
|
||||||
|
if (val ~= nil) then
|
||||||
|
print(val)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# $1 is 0 to disable overscan, 1 to disable it
|
# $1 is 0 to disable overscan, 1 to disable it
|
||||||
set_overscan() {
|
set_overscan() {
|
||||||
# Stop if /boot is not a mountpoint
|
# Stop if /boot is not a mountpoint
|
||||||
@ -141,6 +156,22 @@ do_change_timezone() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
do_memory_split() {
|
do_memory_split() {
|
||||||
|
if [ -e /boot/start_cd.elf ]; then
|
||||||
|
# New-style memory split setting
|
||||||
|
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
|
||||||
|
## 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)
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
set_config_var gpu_mem "$NEW_GPU_MEM" /boot/config.txt
|
||||||
|
ASK_TO_REBOOT=1
|
||||||
|
fi
|
||||||
|
else # Old firmware so do start.elf renaming
|
||||||
get_current_memory_split
|
get_current_memory_split
|
||||||
MEMSPLIT=$(whiptail --menu "Set memory split.\n$MEMSPLIT_DESCRIPTION" 20 60 10 \
|
MEMSPLIT=$(whiptail --menu "Set memory split.\n$MEMSPLIT_DESCRIPTION" 20 60 10 \
|
||||||
"240" "240MiB for ARM, 16MiB for VideoCore" \
|
"240" "240MiB for ARM, 16MiB for VideoCore" \
|
||||||
@ -152,6 +183,7 @@ do_memory_split() {
|
|||||||
set_memory_split ${MEMSPLIT}
|
set_memory_split ${MEMSPLIT}
|
||||||
ASK_TO_REBOOT=1
|
ASK_TO_REBOOT=1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_current_memory_split() {
|
get_current_memory_split() {
|
||||||
|
Loading…
Reference in New Issue
Block a user