From 5c9a0cf40d4e948c263c0e3fffea1c1823c0401f Mon Sep 17 00:00:00 2001 From: Tim Gover Date: Thu, 24 Oct 2019 13:49:00 +0100 Subject: [PATCH] rpi-eeprom-update: Check for vcmailbox, vcgencmd, dtparam, dtoverlay Check for these commands and issue an error indicating how to fix this on Debian. These are all installed by default on Raspbian but this script might be re-used in other-systems e.g. custom busybox builds. --- rpi-eeprom-update | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/rpi-eeprom-update b/rpi-eeprom-update index d313b26..9f5a3de 100755 --- a/rpi-eeprom-update +++ b/rpi-eeprom-update @@ -20,6 +20,7 @@ ENABLE_VL805_UPDATES=${ENABLE_VL805_UPDATES:-1} USE_FLASHROM=${USE_FLASHROM:-0} RECOVERY_BIN=${RECOVERY_BIN:-${FIRMWARE_ROOT}/${FIRMWARE_RELEASE_STATUS}/recovery.bin} BOOTFS=${BOOTFS:-/boot} +VCMAILBOX=${VCMAILBOX:-/opt/vc/bin/vcmailbox} EXIT_SUCCESS=0 EXIT_UPDATE_REQUIRED=1 @@ -161,7 +162,7 @@ applyUpdate() { if [ -f "${BOOTLOADER_UPDATE_IMAGE}" ]; then # Bootloader EEPROM chip-select is muxed with audio pin so disable audio # LDO first to avoid sending noise to analog audio. - /opt/vc/bin/vcmailbox 0x00030056 4 4 0 > /dev/null || true + "${VCMAILBOX}" 0x00030056 4 4 0 > /dev/null || true dtparam audio=off # Switch the SPI pins to boot EEPROM @@ -176,7 +177,7 @@ applyUpdate() { dtparam -R spi-gpio40-45 dtparam audio=on - /opt/vc/bin/vcmailbox 0x00030056 4 4 1 > /dev/null || true + ${VCMAILBOX} 0x00030056 4 4 1 > /dev/null || true fi if [ -f "${VL805_UPDATE_IMAGE}" ]; then @@ -223,6 +224,10 @@ getBootloaderUpdateVersion() { } checkDependencies() { + if ! command -v vcgencmd > /dev/null; then + die "vcgencmd not found. On Debian, try installing the libraspberrypi-bin package." + fi + CPU_VER="$(vcgencmd otp_dump | grep 30: | cut -c8)" if [ "${CPU_VER}" != "3" ]; then @@ -234,24 +239,36 @@ checkDependencies() { die "EEPROM updates directory ${FIRMWARE_IMAGE_DIR} not found." fi - if ! command -v vl805 -h > /dev/null 2>&1; then - die "vl805 command not found" + if ! command -v vl805 > /dev/null; then + die "vl805 command not found. On Debian, try reinstalling the rpi-eeprom package." fi if vcgencmd bootloader_config | grep -qi "Command not registered"; then die "vcgencmd: 'bootloader_config' command not supported. Please update VC firmware and reboot." fi - if ! command -v sha256sum > /dev/null 2>&1; then + if ! command -v sha256sum > /dev/null; then die "sha256sum not found. On Debian, try installing the coreutilities package" fi - if ! command -v flashrom > /dev/null 2>&1; then - [ "${USE_FLASHROM}" = 0 ] || die "flashrom not found. On Debian, try installing the flashrom package." + if ! command -v flashrom > /dev/null && [ "${USE_FLASHROM}" = 1 ]; then + die "flashrom not found. On Debian, try installing the flashrom package." fi - if [ "${USE_FLASHROM}" = 0 ]; then - [ -f "${RECOVERY_BIN}" ] || die "${RECOVERY_BIN} not found." + if [ ! -x "${VCMAILBOX}" ] && [ "${USE_FLASHROM}" = 1 ]; then + die "vcmailbox not found. On Debian, try installing the libraspberrypi-bin package." + fi + + if ! command -v dtparam > /dev/null && [ "${USE_FLASHROM}" = 1 ]; then + die "dtparam not found. On Debian, try installing the libraspberrypi-bin package." + fi + + if ! command -v dtoverlay > /dev/null && [ "${USE_FLASHROM}" = 1 ]; then + die "dtoverlay not found. On Debian, try installing the libraspberrypi-bin package." + fi + + if [ "${USE_FLASHROM}" = 0 ] && [ ! -f "${RECOVERY_BIN}" ]; then + die "${RECOVERY_BIN} not found." fi }