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.
This commit is contained in:
Tim Gover
2019-10-24 13:49:00 +01:00
parent 4c287da760
commit 5c9a0cf40d

View File

@@ -20,6 +20,7 @@ ENABLE_VL805_UPDATES=${ENABLE_VL805_UPDATES:-1}
USE_FLASHROM=${USE_FLASHROM:-0} USE_FLASHROM=${USE_FLASHROM:-0}
RECOVERY_BIN=${RECOVERY_BIN:-${FIRMWARE_ROOT}/${FIRMWARE_RELEASE_STATUS}/recovery.bin} RECOVERY_BIN=${RECOVERY_BIN:-${FIRMWARE_ROOT}/${FIRMWARE_RELEASE_STATUS}/recovery.bin}
BOOTFS=${BOOTFS:-/boot} BOOTFS=${BOOTFS:-/boot}
VCMAILBOX=${VCMAILBOX:-/opt/vc/bin/vcmailbox}
EXIT_SUCCESS=0 EXIT_SUCCESS=0
EXIT_UPDATE_REQUIRED=1 EXIT_UPDATE_REQUIRED=1
@@ -161,7 +162,7 @@ applyUpdate() {
if [ -f "${BOOTLOADER_UPDATE_IMAGE}" ]; then if [ -f "${BOOTLOADER_UPDATE_IMAGE}" ]; then
# Bootloader EEPROM chip-select is muxed with audio pin so disable audio # Bootloader EEPROM chip-select is muxed with audio pin so disable audio
# LDO first to avoid sending noise to analog 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 dtparam audio=off
# Switch the SPI pins to boot EEPROM # Switch the SPI pins to boot EEPROM
@@ -176,7 +177,7 @@ applyUpdate() {
dtparam -R spi-gpio40-45 dtparam -R spi-gpio40-45
dtparam audio=on dtparam audio=on
/opt/vc/bin/vcmailbox 0x00030056 4 4 1 > /dev/null || true ${VCMAILBOX} 0x00030056 4 4 1 > /dev/null || true
fi fi
if [ -f "${VL805_UPDATE_IMAGE}" ]; then if [ -f "${VL805_UPDATE_IMAGE}" ]; then
@@ -223,6 +224,10 @@ getBootloaderUpdateVersion() {
} }
checkDependencies() { 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)" CPU_VER="$(vcgencmd otp_dump | grep 30: | cut -c8)"
if [ "${CPU_VER}" != "3" ]; then if [ "${CPU_VER}" != "3" ]; then
@@ -234,24 +239,36 @@ checkDependencies() {
die "EEPROM updates directory ${FIRMWARE_IMAGE_DIR} not found." die "EEPROM updates directory ${FIRMWARE_IMAGE_DIR} not found."
fi fi
if ! command -v vl805 -h > /dev/null 2>&1; then if ! command -v vl805 > /dev/null; then
die "vl805 command not found" die "vl805 command not found. On Debian, try reinstalling the rpi-eeprom package."
fi fi
if vcgencmd bootloader_config | grep -qi "Command not registered"; then if vcgencmd bootloader_config | grep -qi "Command not registered"; then
die "vcgencmd: 'bootloader_config' command not supported. Please update VC firmware and reboot." die "vcgencmd: 'bootloader_config' command not supported. Please update VC firmware and reboot."
fi 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" die "sha256sum not found. On Debian, try installing the coreutilities package"
fi fi
if ! command -v flashrom > /dev/null 2>&1; then if ! command -v flashrom > /dev/null && [ "${USE_FLASHROM}" = 1 ]; then
[ "${USE_FLASHROM}" = 0 ] || die "flashrom not found. On Debian, try installing the flashrom package." die "flashrom not found. On Debian, try installing the flashrom package."
fi fi
if [ "${USE_FLASHROM}" = 0 ]; then if [ ! -x "${VCMAILBOX}" ] && [ "${USE_FLASHROM}" = 1 ]; then
[ -f "${RECOVERY_BIN}" ] || die "${RECOVERY_BIN} not found." 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 fi
} }