From c33839e47d053a2cf8db33b9891dc7da7b0dd2c6 Mon Sep 17 00:00:00 2001 From: Paul Whalen Date: Apr 24 2018 21:35:12 +0000 Subject: Add help menu to rpi-firmware-update, options for replacing the config.txt and enabling serial console. --- diff --git a/rpi-firmware-update b/rpi-firmware-update index 512b35e..b590e81 100755 --- a/rpi-firmware-update +++ b/rpi-firmware-update @@ -1,5 +1,31 @@ #!/bin/sh +usage() { + echo " +Usage: $(basename ${0}) + --update-config.txt + --enable-serial +" +} +# check the args +while [ $# -gt 0 ]; do + case $1 in + --debug) + set -x + ;; + -h|--help) + usage + exit 0 + ;; + --update-config.txt) + NEW_CONFIG=1 + ;; + --enable-serial) + SERIAL=1 + ;; + esac + shift +done # ensure sudo user if [ "$(whoami)" != "root" ]; then echo "Error: This script requires 'sudo' privileges in order to write to disk & mount media." @@ -43,7 +69,7 @@ if [ "$FW" = "package bcm283x-firmware is not installed" ]; then fi if [ "$FW" = "package bcm283x-firmware is not installed" ] && [ "$UBOOT" = "package ${UBOOTPKG} is not installed" ]; then echo - echo "Nothing to update, exiting." + echo "= Nothing to update, exiting." exit 0 fi echo @@ -55,13 +81,23 @@ if [ "${ARCH}" == "aarch64" ]; then if [ -f /usr/share/uboot/rpi_3/u-boot.bin ]; then cp -rp /usr/share/uboot/rpi_3/u-boot.bin /boot/efi/rpi3-u-boot.bin else - echo "Missing U-Boot for Raspberry Pi 3 Aarch64, no file copied." + echo "= Missing U-Boot for Raspberry Pi 3 Aarch64, no file copied." fi # copy fw if [ -d /usr/share/bcm283x-firmware ]; then cp -rfp /usr/share/bcm283x-firmware/*.{bin,dat,elf} /boot/efi/ + if [ "$NEW_CONFIG" = "1" ]; then + echo "= Using new config.txt." + echo "= Existing config.txt saved as config.txt.old." + mv /boot/efi/config.txt /boot/efi/config.txt.old + cp /usr/share/bcm283x-firmware/config-64.txt /boot/efi/config.txt + fi + if [ "$SERIAL" = "1" ]; then + echo "= Enabling serial console." + sed -i "s|# enable_uart=1|enable_uart=1|" /boot/efi/config.txt + fi else - echo "Missing bcm283x-firmware, no files copied." + echo "= Missing bcm283x-firmware, no files copied." fi else if [ -d /boot/fw ]; then @@ -74,16 +110,26 @@ else if [ -f /usr/share/uboot/rpi_2/u-boot.bin ]; then cp -rp /usr/share/uboot/rpi_2/u-boot.bin /boot/fw/rpi2-u-boot.bin else - echo "Missing U-Boot for Raspberry Pi 2, no file copied." + echo "= Missing U-Boot for Raspberry Pi 2, no file copied." fi if [ -f /usr/share/uboot/rpi_3_32b/u-boot.bin ]; then cp -rp /usr/share/uboot/rpi_3_32b/u-boot.bin /boot/fw/rpi3-u-boot.bin else - echo "Missing U-Boot for Raspberry Pi 3, no file copied." + echo "= Missing U-Boot for Raspberry Pi 3, no file copied." fi # copy fw if [ -d /usr/share/bcm283x-firmware ]; then cp -rfp /usr/share/bcm283x-firmware/*.{bin,dat,elf} /boot/fw/ + if [ "$NEW_CONFIG" = "1" ]; then + echo "= Using new config.txt." + echo "= Existing config.txt saved as config.txt.old." + mv /boot/fw/config.txt /boot/fw/config.txt.old + cp /usr/share/bcm283x-firmware/config.txt /boot/fw/ + fi + if [ "$SERIAL" = "1" ]; then + echo "= Enabling serial console." + sed -i "s|# enable_uart=1|enable_uart=1|" /boot/fw/config.txt + fi else echo "Missing bcm283x-firmware, no files copied." fi @@ -91,4 +137,4 @@ else fi echo echo "== Complete!" -echo \ No newline at end of file +echo