Jul 312012
 

Hey Guys,

Since there has been a new ram split created by the generous Dom, I have updated my Ram selector script to take it into account.
You can get the script from
Here (ad supported)
or
Here.

This adds support for the new ram split if you have it present. It also keeps the old 224/32 ram split if for some reason you still want to use that one.

Script below


#!/bin/bash
##
## Raspberry Pi Memory Split Selector Script v4
## Author: SirLagz
## Website: http://sirlagz.net
##
## The purpose of this script is to make selecting the memory split
## on the RPi easy.
## Simply make this script executable if it's not already, move
## it to the directory with the elf files, and run it with ./select4.sh
## The menu should be pretty self explanatory.
##
cd /boot
clear
list=./*
b128det=0
b192det=0
b224det=0
b240det=0
bdefdet=0

for i in $list
do
case $i in
"./arm128_start.elf") b128det=1;;
"./arm192_start.elf") b192det=1;;
"./arm224_start.elf") b224det=1;;
"./arm240_start.elf") b240det=1;;
"./start.elf") bdefdet=1;;
esac
done

if [[ "$b192det" == "$bdefdet" ]] ; then
if cmp -s arm192_start.elf start.elf; then
current=192
fi
fi

if [[ "$b128det" == "$bdefdet" ]] ; then
if cmp -s arm128_start.elf start.elf; then
current=128
fi
fi

if [[ "$b224det" == "$bdefdet" ]] ; then
if cmp -s arm224_start.elf start.elf; then
current=224
fi
fi

if [[ "$b240det" == "$bdefdet" ]] ; then
if cmp -s arm240_start.elf start.elf; then
current=240
fi
fi

declare -i vram
vram=256-$current
success=1
sysram=`awk '/MemTotal/ { printf("%.0f",$2/1024) }' /proc/meminfo`
echo "##################################"
echo "## Raspberry Pi Memory ##"
echo "## Selector Script ##"
echo "##################################"
echo " Current Memory Split"
echo " CPU $current/$vram VRAM"
echo " Detected System RAM"
echo " $sysram MB"
echo "##################################"
echo "1) Set CPU/VRAM split to 128/128"
echo "2) Set CPU/VRAM split to 192/64"
if [[ "$b240det" == 0 ]] ; then
echo "3) Set CPU/VRAM split to 240/16 (NOT DETECTED. DO NOT USE)"
else
echo "3) Set CPU/VRAM split to 240/16"
fi
if [[ "$b224det" == 1 ]] ; then
echo "4) Set CPU/VRAM split to 224/32"
fi
echo "q) Quit"
echo "Enter Choice:";
read x
case $x in
1)
rm start.elf && cp arm128_start.elf start.elf
newram=128
;;
2)
rm start.elf && cp arm192_start.elf start.elf
newram=192
;;
3)
if [[ "$b240det" == 1 ]] ; then
rm start.elf && cp arm240_start.elf start.elf
newram=240
else
echo "The arm240_start.elf was not detected. Not changing ram split."
success=0
fi
;;
4)
rm start.elf && cp arm224_start.elf start.elf
newram=224
;;
q|Q)
exit 0
;;
*)
$0
;;
esac

if [[ $? -ne 0 ]]; then
echo "Memory Split setting failed"
elif [[ $success == 1 ]]; then
declare -i newvram
newvram=256-$newram
echo "Memory Split set to $newram/$newvram successfully"
fi

for i in $list
do
case $i in
"./arm128_start.elf") b128det=1;;
"./arm192_start.elf") b192det=1;;
"./arm224_start.elf") b224det=1;;
"./arm240_start.elf") b240det=1;;
"./start.elf") bdefdet=1;;
esac
done

if [[ "$bdefdet" -ne 1 ]]; then
$0
echo "=============================================================================="
echo "start.elf not detected. Please check that you have selected a valid ram split."
echo "=============================================================================="
fi

Share
Apr 202012
 

Update – a newer version has been created here.

With the recent release of the Raspberry Pi, a computer designed to make coding and programming easy, fun, and accessible to children of all ages, there has been some discussion on how to change the memory split between the GPU and CPU.
I have come up with a script to make changing the split easy for all the future programmers who aren’t quite comfortable doing it themselves. I’m not a great coder so if you spot any flaws in this please shout out.

You can download the bash script here.
Feedbask is most welcome as I’m looking to improve the script.

Below is the code for the script itself if you want to copy / paste it instead.
If anyone has any suggestions for the script itself or would like some more options, feel free to express yourself in either the comments section on this port or in this thread


#!/bin/bash
##
## Raspberry Pi Memory Split Selector Script
## Author: SirLagz
## Website: http://sirlagz.net
##
## The purpose of this script is to make selecting the memory split
## on the RPi easy.
## Simply make this script executable if it's not already, move
## it to the directory with the elf files, and run it with ./select.sh
## The menu should be pretty self explanatory.
##
clear
list=./*
b128det=0
b192det=0
b224det=0
bdefdet=0

for i in $list
do
case $i in
"./arm128_start.elf") b128det=1;;
"./arm192_start.elf") b192det=1;;
"./arm224_start.elf") b224det=1;;
"./start.elf") bdefdet=1;;
esac
done

if [[ "$b192det" == "$bdefdet" ]] ; then
diffresult=`diff arm192_start.elf start.elf`
if [[ -z $diffresult ]] ; then
mv arm192_start.elf arm192_start.old.elf
b192det=0
fi
fi

if [[ "$b128det" == "$bdefdet" ]] ; then
diffresult=`diff arm128_start.elf start.elf`
if [[ -z $diffresult ]] ; then
mv arm128_start.elf arm128_start.old.elf
b128det=0
fi
fi

if [[ "$b224det" == "$bdefdet" ]] ; then
diffresult=`diff arm224_start.elf start.elf`
if [[ -z $diffresult ]] ; then
mv arm224_start.elf arm224_start.old.elf
b224det=0
fi
fi

if [[ "$b128det" == 0 ]] ; then
current=128
elif [[ "$b192det" == 0 ]] ; then
current=192
elif [[ "$b224det" == 0 ]] ; then
current=224
fi

declare -i vram
vram=256-$current

echo "##################################"
echo "## Raspberry Pi Memory ##"
echo "## Selector Script ##"
echo "##################################"
echo " Current Memory Split"
echo " CPU $current/$vram VRAM"
echo "##################################"
case $current in
128)
echo "1) Set CPU/VRAM split to 192/64"
echo "2) Set CPU/VRAM split to 224/32"
echo "3) Quit"
;;
192)
echo "1) Set CPU/VRAM split to 128/128"
echo "2) Set CPU/VRAM split to 224/32"
echo "3) Quit"
;;
224)
echo "1) Set CPU/VRAM split to 128/128"
echo "2) Set CPU/VRAM split to 192/64"
echo "3) Quit"
;;
*)
echo "Invalid memory detected"
;;
esac
echo "Enter Choice:";
read x

case $x in
1)
case $current in
128)
mv start.elf arm128_start.elf && mv arm192_start.elf start.elf
;;
192)
mv start.elf arm192_start.elf && mv arm128_start.elf start.elf
;;
224)
mv start.elf arm224_start.elf && mv arm128_start.elf start.elf
;;
*)
echo "Invalid memory detected"
;;
esac
;;
2)
case $current in
128)
mv start.elf arm128_start.elf && mv arm224_start.elf start.elf
;;
192)
mv start.elf arm192_start.elf && mv arm224_start.elf start.elf
;;
224)
mv start.elf arm224_start.elf && mv arm192_start.elf start.elf
;;
*)
echo "Invalid memory detected"
;;
esac
;;
3) exit 0;;
esac
if [[ $? -ne 0 ]]; then
echo "Memory Split setting failed"
fi

Share