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

  4 Responses to “New Raspberry Pi Ram Selector Script – Version 4”

  1. Thx for this script.
    Witch version of linux do you use ?

  2. Hi. This script looks handy. However I’d like to try a 96/160 CPU/GPU split to aid playback of 1080p video through XBMC.

    I’m not a shell script guru but it appears that I could probably modify your script to add in a clause for the 96/160 split relatively easily (famous last words). Do you think there’s any reason this would not work?

    • To modify the script is easy. The hard part is actually making the necessary start.elf file.
      Before we go any further though, you should have a look at the current memory usage and see if it exceeds 96 megabytes at any point, and if it does then toss up whether the extra video ram is worth it.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)