From 34929dae281755f9d6dc7f6b958e1c9f03f5f956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laco=20P=C3=A1pay?= Date: Tue, 3 Jul 2012 16:54:07 +0300 Subject: [PATCH 1/6] Added more progress messages in the update sequence. Since it takes a while it is nice to know what the status is. --- rpi-update | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rpi-update b/rpi-update index b2764fb..d5cb788 100755 --- a/rpi-update +++ b/rpi-update @@ -146,9 +146,13 @@ function do_backup { } function do_update { + echo "Updating firmware" update_firmware + echo "Updating modules" update_modules + echo "Updating SDK" update_sdk + echo "Almost done, final tweaks" set_split finalise echo "If no errors appeared, your firmware was successfully $1" From 00f50320c74a71f844ae757eae081aea6cf20afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bengt=20L=C3=BCers?= Date: Mon, 9 Jul 2012 23:50:32 +0200 Subject: [PATCH 2/6] githubified the readme --- README.md | 84 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 535a11f..2f0fe33 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,75 @@ -rpi-update -========== +# rpi-update An easier way to update the firmware of your Raspberry Pi -Instructions ------------- +## Status -To install the tool, run the following command as root: +This tool is experimental, and may screw up your install. If you have problems +with it, post an issue to this GitHub repo and I'll see if I can help you. -
-wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && chmod +x /usr/bin/rpi-update
-
+## Preparations -If you get errors relating to certificates, then the problem is likely due to one of two things. Either the time is set incorrectly on your Raspberry Pi, which you can fix by simply setting the time using NTP. The other possible issue is that you might not have the ca-certificates package installed, and so GitHub's SSL certificate isn't trusted. If you're on Debian, you can resolve this by typing: +To prevent errors relating certificates, one can fix two possible problems. -
-sudo apt-get install ca-certificates
-
+- Either the time is set incorrectly on your Raspberry Pi, which you can fix + by simply setting the time using NTP. -To then update your firmware, simply run the following command as root: + sudo ntpdate -u ntp.ubuntu.com -
-rpi-update
-
+- The other possible issue is that you might not have the ca-certificates + package installed, and so GitHub's SSL certificate isn't trusted. If you are + on Debian, you can resolve this by typing: + sudo apt-get install ca-certificates -By default, rpi-update will attempt to determine the split you're currently using, and then use that split. If it cannot determine what split you are using, it will default to 224MB. +## Installing -If you'd like to explicitly select a split, simply provide the RAM split value after the command as follows: +To install the tool, run the following command: -
-rpi-update 192
-
+ sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && chmod +x /usr/bin/rpi-update -If you'd like to use the 128MB memory split, then the command is the same as the above, except with 128 instead of 192. +## Updating -After the firmware has been sucessfully updated, you'll need to reboot to load the new firmware. +To then update your firmware, simply run the following command: -This tool is experimental, and may screw up your install. If you have problems with it, post an issue to this GitHub repo and I'll see if I can help you. + sudo rpi-update + +### Options -Expert options --------------- +By default, rpi-update will attempt to determine the split you're currently +using, and then use that split. If it cannot determine what split you are using, +it will default to 224MB. If you'd like to explicitly select a split, simply +provide the RAM split value after the command as follows: -There are a number of options for experts you might like to use, these are all environment variables you must set if you wish to use them. + sudo rpi-update 192 -### SKIP_KERNEL +If you'd like to use the 128MB memory split, then the command is the same as the +above, except with 128 instead of 192: -#### Usage + sudo rpi-update 128 -SKIP_KERNEL=1 rpi-update +### Environment Variables -#### Effect +There are a number of options for experts you might like to use, these are all +environment variables you must set if you wish to use them. -Will update everything EXCEPT the kernel.img files and the kernel modules. Use with caution, some firmware updates might depend a kernel update. +#### SKIP_KERNEL -### ROOT_PATH/BOOT_PATH + sudo SKIP_KERNEL=1 rpi-update -#### Usage +Will update everything **except** the kernel.img files and the kernel modules. +Use with caution, some firmware updates might depend a kernel update. -ROOT_PATH=/media/root BOOT_PATH=/media/boot rpi-update +#### ROOT_PATH/BOOT_PATH -#### Effect + sudo ROOT_PATH=/media/root BOOT_PATH=/media/boot rpi-update -Allows you to perform an "offline" update, ie update firmware on an SD card you're not currently booted from. Useful for installing firmware/kernel to a non-RPI customised image. Be careful, you must specify both options or neither. Specifying only one will not work. +Allows you to perform an "offline" update, ie update firmware on an SD card you +are not currently booted from. Useful for installing firmware/kernel to a +non-RPI customised image. Be careful, you must specify both options or neither. +Specifying only one will not work. + +## Activating + +After the firmware has been sucessfully updated, you'll need to reboot to load +the new firmware. From 4c690228f7a31b671bd1b54377c822e116f5882a Mon Sep 17 00:00:00 2001 From: James Nylen Date: Wed, 24 Oct 2012 15:01:54 +0000 Subject: [PATCH 3/6] Remove '--quiet' and '-q' options to git and wget --- rpi-update | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rpi-update b/rpi-update index d156e4c..2300d10 100755 --- a/rpi-update +++ b/rpi-update @@ -28,7 +28,7 @@ function update_self() { echo "Performing self-update" _tempFileName="$0.tmp" - if ! wget --quiet --output-document="${_tempFileName}" "${UPDATE_URI}"; then + if ! wget --output-document="${_tempFileName}" "${UPDATE_URI}"; then echo "Failed to download update for rpi-update!" echo "Make sure you have ca-certificates installed and that the time is set correctly" exit 1 @@ -36,7 +36,7 @@ function update_self() { OCTAL_MODE=$(stat -c '%a' "$0") if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then - echo "Failed: Error while trying to set mode on ${_tempFileName}" + echo "Failed: Error while trying to set mode on ${_tempFileName}" exit 1 fi @@ -107,7 +107,7 @@ function finalise { function download_repo { echo "Setting up firmware (this will take a few minutes)" mkdir -p "${FW_REPOLOCAL}" - git clone "${FW_REPO}" "${FW_REPOLOCAL}" --depth=1 --quiet + git clone "${FW_REPO}" "${FW_REPOLOCAL}" --depth=1 RETVAL=$? if [[ ${RETVAL} -ne 0 ]]; then echo "Failed to download new firmware files" @@ -117,15 +117,15 @@ function download_repo { function update_repo { echo "Updating firmware (this will take a few minutes)" - eval ${GITCMD} fetch --quiet + eval ${GITCMD} fetch RETVAL=$? if [[ ${RETVAL} -ne 0 ]]; then echo "Failed to download updated firmware files" exit 1 fi - eval ${GITCMD} reset --hard --quiet - eval ${GITCMD} clean -f -d --quiet - eval ${GITCMD} merge origin/master -m "automerge" --quiet + eval ${GITCMD} reset --hard + eval ${GITCMD} clean -f -d + eval ${GITCMD} merge origin/master -m "automerge" RETVAL=$? if [[ ${RETVAL} -ne 0 ]]; then echo "Failed to download updated firmware files" @@ -156,7 +156,7 @@ function do_update { function download_rev { echo "Downloading specific firmware revision (this will take a few minutes)" mkdir -p "${FW_REPOLOCAL}" - wget -q "${REPO_URI}/tarball/${FW_REV}" -O "${FW_REPOLOCAL}/${FW_REV}.tar.gz" + wget "${REPO_URI}/tarball/${FW_REV}" -O "${FW_REPOLOCAL}/${FW_REV}.tar.gz" tar xzf "${FW_REPOLOCAL}/${FW_REV}.tar.gz" -C "${FW_REPOLOCAL}" --strip-components=1 rm "${FW_REPOLOCAL}/${FW_REV}.tar.gz" } From 1361c8fc2993e4bcc656bc3a6e86dc1f172eed29 Mon Sep 17 00:00:00 2001 From: James Nylen Date: Wed, 24 Oct 2012 15:05:43 +0000 Subject: [PATCH 4/6] Add option to disable self-updating --- README.md | 7 +++++++ rpi-update | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index de9ce36..0706593 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,13 @@ To upgrade/downgrade to a specific firmware revision, specify its Git hash There are a number of options for experts you might like to use. These are all environment variables you must set if you wish to use them. +#### `UPDATE_SELF` + +By default, `rpi-update` will attempt to update itself each time it is run. +You can disable this behavior by: + + UPDATE_SELF=0 sudo rpi-update + #### `SKIP_KERNEL` SKIP_KERNEL=1 sudo rpi-update diff --git a/rpi-update b/rpi-update index 2300d10..30e9482 100755 --- a/rpi-update +++ b/rpi-update @@ -5,7 +5,7 @@ set -o errexit REPO_URI="http://github.com/Hexxeh/rpi-firmware" -UPDATE2=${UPDATE2:-1} +UPDATE_SELF=${UPDATE_SELF:-1} UPDATE_URI="https://github.com/Hexxeh/rpi-update/raw/master/rpi-update" if [[ ${BOOT_PATH:-"unset"} == "unset" && ${ROOT_PATH:-"unset"} != "unset" ]] || @@ -44,7 +44,7 @@ function update_self() { #!/bin/bash if mv "${_tempFileName}" "$0"; then rm -- "\$0" - exec env UPDATE2=0 /bin/bash "$0" "${FW_REV}" + exec env UPDATE_SELF=0 /bin/bash "$0" "${FW_REV}" else echo "Failed!" fi @@ -166,8 +166,9 @@ if [[ ${EUID} -ne 0 ]]; then exit 1 fi -if [[ ${UPDATE2} -ne 0 ]]; then - echo "Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS" +echo "Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS" + +if [[ ${UPDATE_SELF} -ne 0 ]]; then update_self fi From f262b92ed0ff2c3cc68728fa7a4e21b59dbb264e Mon Sep 17 00:00:00 2001 From: James Nylen Date: Wed, 24 Oct 2012 15:15:54 +0000 Subject: [PATCH 5/6] Fix setting environment variables with sudo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0706593..fd939f8 100644 --- a/README.md +++ b/README.md @@ -55,18 +55,18 @@ environment variables you must set if you wish to use them. By default, `rpi-update` will attempt to update itself each time it is run. You can disable this behavior by: - UPDATE_SELF=0 sudo rpi-update + sudo UPDATE_SELF=0 rpi-update #### `SKIP_KERNEL` - SKIP_KERNEL=1 sudo rpi-update + sudo SKIP_KERNEL=1 rpi-update Will update everything **except** the `kernel.img` files and the kernel modules. Use with caution, some firmware updates might depend on a kernel update. #### `ROOT_PATH` and `BOOT_PATH` - ROOT_PATH=/media/root BOOT_PATH=/media/boot sudo rpi-update + sudo ROOT_PATH=/media/root BOOT_PATH=/media/boot rpi-update Allows you to perform an "offline" update, ie update firmware on an SD card you are not currently booted from. Useful for installing firmware/kernel to a From 4652f64a4d52f9f8227c3d338b4bbef32b41f62b Mon Sep 17 00:00:00 2001 From: James Nylen Date: Wed, 24 Oct 2012 15:16:23 +0000 Subject: [PATCH 6/6] Further improve progress messages --- rpi-update | 101 +++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/rpi-update b/rpi-update index 30e9482..f7aa752 100755 --- a/rpi-update +++ b/rpi-update @@ -10,7 +10,7 @@ UPDATE_URI="https://github.com/Hexxeh/rpi-update/raw/master/rpi-update" if [[ ${BOOT_PATH:-"unset"} == "unset" && ${ROOT_PATH:-"unset"} != "unset" ]] || [[ ${BOOT_PATH:-"unset"} != "unset" && ${ROOT_PATH:-"unset"} == "unset" ]]; then - echo "You need to specify both ROOT_PATH and BOOT_PATH, or neither" + echo " *** You need to specify both ROOT_PATH and BOOT_PATH, or neither" exit 1 fi @@ -25,18 +25,18 @@ FW_REV=${1:-""} GITCMD="git --git-dir=\"${FW_REPOLOCAL}/.git\" --work-tree=\"${FW_REPOLOCAL}\"" function update_self() { - echo "Performing self-update" + echo " *** Performing self-update" _tempFileName="$0.tmp" if ! wget --output-document="${_tempFileName}" "${UPDATE_URI}"; then - echo "Failed to download update for rpi-update!" - echo "Make sure you have ca-certificates installed and that the time is set correctly" + echo " !!! Failed to download update for rpi-update!" + echo " !!! Make sure you have ca-certificates installed and that the time is set correctly" exit 1 fi OCTAL_MODE=$(stat -c '%a' "$0") if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then - echo "Failed: Error while trying to set mode on ${_tempFileName}" + echo " !!! Failed: Error while trying to set mode on ${_tempFileName}" exit 1 fi @@ -46,36 +46,43 @@ function update_self() { rm -- "\$0" exec env UPDATE_SELF=0 /bin/bash "$0" "${FW_REV}" else - echo "Failed!" + echo " !!! Failed!" fi EOF + echo " *** Relaunching after update" exec /bin/bash /tmp/updateScript.sh } function update_modules { if [[ ${SKIP_KERNEL} -eq 0 ]]; then - cp -R "${FW_REPOLOCAL}/modules/"* "${FW_MODPATH}/" + echo " *** Updating modules" + cp -vR "${FW_REPOLOCAL}/modules/"* "${FW_MODPATH}/" find "${FW_REPOLOCAL}/modules" -mindepth 1 -maxdepth 1 -type d | while read DIR; do + echo " *** depmod $(basename "${DIR}")" depmod -b "${ROOT_PATH}" -a $(basename "${DIR}") done + else + echo " *** As requested, not updating modules" fi } function update_sdk { + echo " *** Updating SDK" + if [[ -f /etc/init.d/vcfiled ]]; then /etc/init.d/vcfiled stop fi ELFOUTPUT=$(readelf -a "${ROOT_PATH}/bin/bash") if [ "${ELFOUTPUT}" != "${ELFOUTPUT/VFP_args/}" ]; then - echo "Using HardFP libraries" - cp -R "${FW_REPOLOCAL}/vc/hardfp/"* "${ROOT_PATH}/" + echo " *** Using HardFP libraries" + cp -vR "${FW_REPOLOCAL}/vc/hardfp/"* "${ROOT_PATH}/" else - echo "Using SoftFP libraries" - cp -R "${FW_REPOLOCAL}/vc/softfp/"* "${ROOT_PATH}/" + echo " *** Using SoftFP libraries" + cp -vR "${FW_REPOLOCAL}/vc/softfp/"* "${ROOT_PATH}/" fi - cp -R "${FW_REPOLOCAL}/vc/sdk/"* "${ROOT_PATH}/" + cp -vR "${FW_REPOLOCAL}/vc/sdk/"* "${ROOT_PATH}/" if [[ -f /etc/init.d/vcfiled ]]; then /etc/init.d/vcfiled start @@ -83,44 +90,49 @@ function update_sdk { } function update_firmware { + echo " *** Updating firmware" rm -rf ${FW_PATH}/*.elf rm -rf ${FW_PATH}/*.bin - cp ${FW_REPOLOCAL}/*.elf "${FW_PATH}/" - cp ${FW_REPOLOCAL}/*.bin "${FW_PATH}/" - cp ${FW_REPOLOCAL}/*.dat "${FW_PATH}/" + cp -v ${FW_REPOLOCAL}/*.elf "${FW_PATH}/" + cp -v ${FW_REPOLOCAL}/*.bin "${FW_PATH}/" + cp -v ${FW_REPOLOCAL}/*.dat "${FW_PATH}/" if [[ ${SKIP_KERNEL} -eq 0 ]]; then - cp "${FW_REPOLOCAL}/"*.img "${FW_PATH}/" + cp -v "${FW_REPOLOCAL}/"*.img "${FW_PATH}/" else - echo "Skipping kernel/modules updated as requested" + echo " *** As requested, not updating kernel" fi } function finalise { if [[ -f "${FW_PATH}/arm192_start.elf" ]]; then - cp "${FW_PATH}/arm192_start.elf" "${FW_PATH}/start.elf" + echo " *** Setting 192M ARM split" + cp -v "${FW_PATH}/arm192_start.elf" "${FW_PATH}/start.elf" fi + echo " *** Running ldconfig" ldconfig -r "${ROOT_PATH}" + echo " *** Storing current firmware revision" eval ${GITCMD} rev-parse master > "${FW_PATH}/.firmware_revision" + echo " *** Syncing changes to disk" sync } function download_repo { - echo "Setting up firmware (this will take a few minutes)" + echo " *** Setting up firmware (this may take a few minutes)" mkdir -p "${FW_REPOLOCAL}" git clone "${FW_REPO}" "${FW_REPOLOCAL}" --depth=1 RETVAL=$? if [[ ${RETVAL} -ne 0 ]]; then - echo "Failed to download new firmware files" + echo " !!! Failed to download new firmware files" exit 1 fi } function update_repo { - echo "Updating firmware (this will take a few minutes)" + echo " *** Updating firmware (this may take a few minutes)" eval ${GITCMD} fetch RETVAL=$? if [[ ${RETVAL} -ne 0 ]]; then - echo "Failed to download updated firmware files" + echo " !!! Failed to download updated firmware files" exit 1 fi eval ${GITCMD} reset --hard @@ -128,33 +140,30 @@ function update_repo { eval ${GITCMD} merge origin/master -m "automerge" RETVAL=$? if [[ ${RETVAL} -ne 0 ]]; then - echo "Failed to download updated firmware files" + echo " !!! Failed to download updated firmware files" exit 1 fi } function do_backup { - cp -a "${FW_PATH}" "${FW_PATH}.bak" - cp -a "${FW_MODPATH}" "${FW_MODPATH}.bak" + echo " *** Backing up files" + cp -va "${FW_PATH}" "${FW_PATH}.bak" + cp -va "${FW_MODPATH}" "${FW_MODPATH}.bak" } function do_update { - echo "Updating firmware" update_firmware - echo "Updating modules" update_modules - echo "Updating SDK" update_sdk - echo "Almost done, final tweaks" finalise - echo "If no errors appeared, your firmware was successfully $1" + echo " *** If no errors appeared, your firmware was successfully $1" if [[ "${ROOT_PATH}" == "/" ]]; then - echo "A reboot is needed to activate the new firmware" + echo " *** A reboot is needed to activate the new firmware" fi } function download_rev { - echo "Downloading specific firmware revision (this will take a few minutes)" + echo " *** Downloading specific firmware revision (this will take a few minutes)" mkdir -p "${FW_REPOLOCAL}" wget "${REPO_URI}/tarball/${FW_REV}" -O "${FW_REPOLOCAL}/${FW_REV}.tar.gz" tar xzf "${FW_REPOLOCAL}/${FW_REV}.tar.gz" -C "${FW_REPOLOCAL}" --strip-components=1 @@ -162,57 +171,57 @@ function download_rev { } if [[ ${EUID} -ne 0 ]]; then - echo "This tool must be run as root" + echo " !!! This tool must be run as root" exit 1 fi -echo "Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS" +echo " *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS" if [[ ${UPDATE_SELF} -ne 0 ]]; then update_self fi if [[ ! -d "${FW_PATH}" ]]; then - echo "${FW_PATH} doesn't exist" + echo " !!! ${FW_PATH} doesn't exist" exit 1 fi if [[ ! -f "${FW_PATH}/start.elf" ]]; then - echo "${FW_PATH}/start.elf doesn't exist." + echo " !!! ${FW_PATH}/start.elf doesn't exist." exit 1 fi if [[ ! -d "${FW_MODPATH}" ]]; then - echo "${FW_MODPATH} doesn't exist" + echo " !!! ${FW_MODPATH} doesn't exist" exit 1 fi command -v git >/dev/null 2>&1 || { - echo "This tool requires you have Git installed, please install it first" - echo "In Debian, try: sudo apt-get install git-core" - echo "In Arch, try: pacman -S git" + echo " !!! This tool requires you have Git installed, please install it first" + echo " In Debian, try: sudo apt-get install git-core" + echo " In Arch, try: pacman -S git" exit 1 } command -v readelf >/dev/null 2>&1 || { - echo "This tool requires you have readelf installed, please install it first" - echo "In Debian, try: sudo apt-get install binutils" - echo "In Arch, try: pacman -S binutils" + echo " !!! This tool requires you have readelf installed, please install it first" + echo " In Debian, try: sudo apt-get install binutils" + echo " In Arch, try: pacman -S binutils" exit 1 } -echo "ARM/GPU split is now defined in /boot/config.txt using the gpu_mem option!" +echo " *** ARM/GPU split is now defined in /boot/config.txt using the gpu_mem option!" if [[ ${FW_REV} != "" ]]; then download_rev do_update "updated to revision ${FW_REV}" elif [[ -f "${FW_REPOLOCAL}/.git/config" ]]; then update_repo if [[ -f "${FW_PATH}/.firmware_revision" ]] && [[ $(cat "${FW_PATH}/.firmware_revision") == $(eval ${GITCMD} rev-parse master) ]]; then - echo "Your firmware is already up to date" + echo " *** Your firmware is already up to date" finalise else do_update "updated" fi else - echo "We're running for the first time" + echo " *** We're running for the first time" download_repo do_backup do_update "setup"