Skip to content
Newer
Older
100755 49 lines (41 sloc) 1.41 KB
9805f8f @Hexxeh Added initial version of update tool
authored Apr 21, 2012
1 #!/bin/bash
2
3 FW_REPO="git://github.com/Hexxeh/rpi-firmware.git"
4 FW_PATH="/boot"
5 FW_RAM=${1:-224}
6 FW_GPU=$((256-FW_RAM))
7
8 echo "Raspberry Pi firmware updater by Hexxeh"
48b6de4 @Hexxeh Add check for root
authored Apr 21, 2012
9
10 if [[ $EUID -ne 0 ]]; then
7d3154e @Hexxeh Add check to make sure Git is installed before we attempt update/setup
authored Apr 21, 2012
11 echo "This tool must be run as root"
48b6de4 @Hexxeh Add check for root
authored Apr 21, 2012
12 exit 1
13 fi
14
7d3154e @Hexxeh Add check to make sure Git is installed before we attempt update/setup
authored Apr 21, 2012
15 command -v git >/dev/null 2>&1 || {
16 echo "This tool requires you have Git installed, please install it first"
17 echo "In Debian, try: sudo apt-get install git-core"
18 echo "In Arch, try: pacman -Sy git"
19 exit 1
20 }
21
9805f8f @Hexxeh Added initial version of update tool
authored Apr 21, 2012
22 echo "Using memory split of ${FW_RAM}MB/${FW_GPU}MB"
23
24 GITCMD="git --git-dir=${FW_PATH}/.git --work-tree=${FW_PATH}"
25
26 if $($GITCMD rev-parse &> /dev/null); then
27 echo "Updating firmware (this will take a few minutes)"
28 rm -f ${FW_PATH}/start.elf
29 $GITCMD fetch --quiet
30 $GITCMD merge origin/master --no-edit --quiet
31 cp ${FW_PATH}/arm${FW_RAM}_start.elf ${FW_PATH}/start.elf
32 echo "If no errors appeared, your firmware was successfully updated"
33 else
34 echo "We're running for the first time"
35 echo "Setting up firmware (this will take a few minutes)"
36 cp -R ${FW_PATH} ${FW_PATH}.bak
37 rm -rf /boot/*
38 git clone ${FW_REPO} ${FW_PATH} --depth=1 --quiet
39 RETVAL=$?
40 if [[ $RETVAL != 0 ]]; then
41 echo "We failed! Attmepting to restore your original firmware"
42 cp -R ${FW_PATH}.bak ${FW_PATH}
43 else
44 cp ${FW_PATH}.bak/*.txt ${FW_PATH}/ &> /dev/null
45 cp ${FW_PATH}/arm${FW_RAM}_start.elf ${FW_PATH}/start.elf
46 echo "If no errors appeared, your firmware was successfully setup"
47 fi
48 fi
Something went wrong with that request. Please try again.