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
Apr 132012
 

Hey Everyone

I have just finished making my very first bash script. It’s called Simple Log File Monitor as you may have guessed.
It reads in a log file, either from the beginning or from a mark that the script has set before, then it can perform a user defined action to the output of the log file after it has been read.
It will then apply an action to the resultant output of the logfile, e.g. email it to you.

I have written it in shell script in order for it to be small, and as reliant on as little as possible.
You should be able to run this script with just bash, awk, grep, tail, date, and wc.
The purpose of this was for a router that I plan to build. I didn’t want to install perl onto it as it will have miniscule storage, so I thought this was a better option. This script should also work on any embedded devices that have the required utilities installed, so if there is anyone out there who has one of those, I’d appreciate any testing that could be done on those devices.

This script allows you to set a configuration file with the -c switch when you run the script, but if you don’t set it, the script will use the default slfm.conf that should be located in the same directory as the script itself.

This allows you to customise when the log file is monitored, and which files are monitored by running the script at certain intervals with different command line parameters.
So the script will show the last hours worth of logs if the script is run hourly.

The script will mark it’s position so that it won’t have to read the whole entire logfile again, and then it can redirect the output of the logfile to anywhere. For example it can email you the results, or it can append the results to a file.

The documentation on this isn’t great at the moment so any help with that would be appreciated.
If anyone could please try this script out and provide feedback in the comments section, that would be great.
As this is my first script, please be gentle 😀 but I’m open to any suggestions on how to make this better.

This script can be downloaded from my sourceforge page.
It has a sample configuration file already included to help you get started. Hopefully it’s understandable enough and clear enough to everyone and easy enough to work with.
Hope to hear back from some new users 😀

Share