24

By default, the Pi is set to a 192MiB:64MiB RAM:VRAM split. As I will not be using the Pi for graphical purposes, I would like to change the split to allocate more normal RAM to ease swap usage.

tlhIngan
  • 3,342
  • 5
  • 18
  • 33
hifkanotiks
  • 1,861
  • 3
  • 15
  • 28
  • There is a similar question and relevant answer [here](http://raspberrypi.stackexchange.com/q/673/40). – Jivings Aug 22 '12 at 16:54

3 Answers3

17

These are the RAM splits and what they should be used for.

  • 240/16 - This is best if you are going to be doing nothing graphical, for example if you were using the Pi as a server and have no GUI.
  • 224/32 - This is probably best if you are using the pi with a basic graphical desktop environment, without 3D.
  • 192/64 - The default, probably the best general purpose one.
  • 128/128 - Very high VRAM, Only really good if you are doing a very graphically intensive task.

There are several methods by which the RAM split can be managed:

Manually

You can change the RAM split using this method:

sudo cp /boot/arm[ram-split]_start.elf /boot/start.elf

where [ram-split] is the amount of RAM to allocate to the CPU. After a reboot the new value will be applied.

rpi-update

Hexxeh's rpi-update also supports changing the RAM split, you would run rpi-update [ram-split] where [ram-split] is the amount of RAM you want allocated to the CPU. After a reboot the split will be applied.

Ram Selector Script

The best way is probably to use this select4.sh script, then selecting the appropriate RAM split. After you reboot the new split will be applied.

#!/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

Here's a github link in case of link rot.

John D
  • 103
  • 4
hifkanotiks
  • 1,861
  • 3
  • 15
  • 28
  • does it require a reboot afterwards? – akavel Aug 22 '12 at 13:43
  • @akavel Yes, as the start.elf is only executed upon startup. Editing now. – hifkanotiks Aug 22 '12 at 13:50
  • 1
    The four answers you posted have been merged. Although sometimes acceptable, I don't believe that having four separate answers addressing different aspects of the question added any value in this case. I hope no-one objects. – Jivings Aug 22 '12 at 16:51
14

raspi-config

You can change the memory split using the raspi-config utility in either debian-wheezy or raspbian-wheezy.

Just run the utility: sudo raspi-config then select the memory split option (its about the 8th one in the list).

Jon Egerton
  • 2,983
  • 2
  • 21
  • 31
2

Checking your RAM split

Too big for a comment, but related. You can check your ram split by running this command

$ sha1sum /boot/*start.elf
a3f72ae7eae537800454de8e4cb231cbd176c0e1  /boot/arm128_start.elf
7784527719031c1c7fce6f72cf3a5c8c23565f24  /boot/arm192_start.elf
82c6be2c9098c0c9c3d71f45bf16c1dc5adfcf08  /boot/arm224_start.elf
82c6be2c9098c0c9c3d71f45bf16c1dc5adfcf08  /boot/start.elf

The split is given by the file that has the matching checksum, so in my case it's 224/32

Alex Chamberlain
  • 15,120
  • 13
  • 63
  • 112
John La Rooy
  • 11,847
  • 9
  • 46
  • 74
  • Although useful, this doesn't answer the question. – Jivings Aug 22 '12 at 16:46
  • I wanted to check my current ram split because I didn't know what the default was and it wasn't called out in /boot/config.txt. Unfortunately my system only had start.elf, so I tracked down the value through dmesg. There's a line (on my system) that says "Memory: 448MB = 448MB total". So I have a 448/64 split. – GrandAdmiral May 14 '13 at 21:09