Merge branch 'master' into debian/buster

This commit is contained in:
Serge Schneider
2020-01-13 11:00:45 +00:00
11 changed files with 161 additions and 60 deletions

View File

@@ -1,2 +1,27 @@
# rpi-eeprom
This repository contains the scripts and pre-compiled binaries used to create the rpi-eeprom package which is used to update the Raspberry Pi4 bootloader EEPROM.
# Support
For bootloader support the best place to start is the Raspberry Pi [General Users forum](https://www.raspberrypi.org/forums/viewforum.php?f=63) or for discussion of beta releases try the [Advanced Users forum](https://www.raspberrypi.org/forums/viewforum.php?f=29&sid=9bbc277968ad953e77749b255d0ce3a2)
# Rescue image
If the Raspberry Pi4 is not booting, then it's very unlikely that the EEPROM is corrupted. If you think it has an invalid image or you want to revert to the factory setting, then download the rescue image from the Raspberry Pi [downloads page](https://www.raspberrypi.org/downloads/)
# Bootloader documentation
* [The boot folder](https://www.raspberrypi.org/documentation/configuration/boot_folder.md)
* [Config.txt boot options](https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md)
* [Bootloader EEPROM](https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md)
* [Bootloader configuration](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711_bootloader_config.md)
# Bug reports
Bootloader bugs are especially difficult to describe because there's no display. Where possible please include the following information in order to help identify the problem.
* EEPROM version (vcgencmd bootloader_version or the pieeprom filename)
* EEPROM config (from rpi-eeprom-config)
* UART trace using USB serial cable
* Wireshark trace for network boot. Filtering for DHCP and TFTP protocols or by mac-address for the Pi4 is fine.
# BETA versions of the bootloader
If you want to try the BETA version of the bootloader then we recommend that you always try this with a spare sd-card and comfortable with using the rescue image. For debugging you may find a USB serial cable useful.
Beta features are always documented [here](https://github.com/raspberrypi/rpi-eeprom/blob/master/firmware/raspberry_pi4_network_boot_beta.md) first. Once the configuration has stabalised then the [Bootloader configuration](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711_bootloader_config.md) will be updated, however, there's normally a bit of a delay in order to allow official documentation to be reviewed.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
000137ab
000137ad

View File

@@ -1,5 +1,13 @@
# Raspberry Pi4 bootloader EEPROM release notes
## 2020-01-09 - Git df0ff18c (BETA) RC3
* Fix parsing of multiple menu entries in PXE options.
* Fix regression in IP address parsing
## 2019-12-03 - Git f0d7269d4 (BETA) RC2
* Fix handling of multiple menu options with TFTP Option43
* Ignore unsupported modes in BOOT_ORDER instead of stopping.
## 2019-11-18 - Git b6a7593d6 (BETA) RC1
First release candidate before this beta is moved to a stable release series.

View File

@@ -97,10 +97,27 @@ class BootloaderImage(object):
sys.stdout.write(config_bytes)
def main():
parser = argparse.ArgumentParser('RPI EEPROM config tool')
parser.add_argument('--config', help='Filename of new bootloader config')
parser.add_argument('--out', help='Filename for the EEPROM image with updated config')
parser.add_argument('eeprom', help='EEPROM filename (pieeprom.bin)')
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, \
description='Bootloader EEPROM configuration tool for the Raspberry Pi 4B. \
\n\nThere are 3 operating modes: \
\n\n1. Output the bootloader configuration stored in an EEPROM image file to \
the screen (STDOUT): specify only the name of an EEPROM image file using the \
\'eeprom\' option. \
\n\n2. Output the bootloader configuration stored in an EEPROM image file to a \
file: specify the EEPROM image file using the \'eeprom\' option, and the output \
file using the \'--out\' option.\
\n\n3. Insert a new bootloader configuration into an EEPROM image file: specify \
the source EEPROM image file using the \'eeprom\' option and the bootloader \
configuration file using the \'--config\' option. A new file which is a \
combination of the EEPROM image file, together with the new bootloader \
configuration file will be created - specify its name using the \'--out\' option. \
The new bootloader configuration will replace any configuration present in the \
source EEPROM image.\
\n\nBootloader EEPROM images are contained in the \'rpi-eeprom-images\' package,\
which installs them to the /lib/firmware/raspberrypi/bootloader directory.')
parser.add_argument('--config', help='Name of bootloader configuration file')
parser.add_argument('--out', help='Name of output file')
parser.add_argument('eeprom', help='Name of EEPROM file to use as input')
args = parser.parse_args()
image = BootloaderImage(args.eeprom, args.out)

View File

@@ -35,6 +35,7 @@ SPI_SPEED=16000
# Timestamp for first release which doesn't have a timestamp field
BOOTLOADER_FIRST_VERSION=1557513636
EEPROM_SIZE=524288
BOARD_REVISION=
# Simple bootloader which is able to load start.elf in the event of a power
# cut. This runs SDRAM at low speed and may have reduced functionality but
@@ -57,6 +58,9 @@ cleanup() {
if [ -f "${TMP_EEPROM_CONFIG}" ]; then
rm -f "${TMP_EEPROM_CONFIG}"
fi
if [ -f "${NEW_EEPROM_CONFIG}" ]; then
rm -f "${NEW_EEPROM_CONFIG}"
fi
if [ -d "${TMP_BOOTFS_MNT}" ]; then
umount "${TMP_BOOTFS_MNT}"
rmdir "${TMP_BOOTFS_MNT}"
@@ -64,6 +68,7 @@ cleanup() {
TMP_BOOTFS_MNT=
TMP_EEPROM_IMAGE=
TMP_EEPROM_CONFIG=
NEW_EEPROM_CONFIG=
}
trap cleanup EXIT
@@ -77,6 +82,7 @@ prepareImage()
[ -f "${BOOTLOADER_UPDATE_IMAGE}" ] || die "EEPROM image \'${BOOTLOADER_UPDATE_IMAGE}\' not found"
TMP_EEPROM_IMAGE="$(mktemp)"
TMP_EEPROM_CONFIG="$(mktemp)"
NEW_EEPROM_CONFIG="$(mktemp)"
mkdir -p "${FIRMWARE_BACKUP_DIR}"
@@ -85,7 +91,17 @@ prepareImage()
backup="${FIRMWARE_BACKUP_DIR}/pieeprom-backup-$(date +%Y%m%d-%H%M%S).conf"
cp -f "${TMP_EEPROM_CONFIG}" "${backup}"
if [ "$(wc -l "${TMP_EEPROM_CONFIG}" | awk '{print $1}')" -lt 3 ]; then
if [ -x "${EEPROM_CONFIG_HOOK}" ]; then
echo "Running EEPROM config hook ${EEPROM_CONFIG_HOOK}"
if ! "${EEPROM_CONFIG_HOOK}" -u "${BOOTLOADER_UPDATE_IMAGE}" < "${TMP_EEPROM_CONFIG}" > "${NEW_EEPROM_CONFIG}"; then
echo "EEPROM config hook \"${EEPROM_CONFIG_HOOK}\" failed. Using original configuration"
cp -f "${TMP_EEPROM_CONFIG}" "${NEW_EEPROM_CONFIG}"
fi
else
cp -f "${TMP_EEPROM_CONFIG}" "${NEW_EEPROM_CONFIG}"
fi
if [ "$(wc -l "${NEW_EEPROM_CONFIG}" | awk '{print $1}')" -lt 3 ]; then
# Don't propagate empty EEPROM config files and also prevent the initial
# bootloader config with WAKE_ON_GPIO=0 propgating to newer versions by
# accident.
@@ -97,7 +113,7 @@ prepareImage()
if [ "${OVERWRITE_CONFIG}" = 0 ]; then
"${script_dir}/rpi-eeprom-config" \
--out "${TMP_EEPROM_IMAGE}" \
--config "${TMP_EEPROM_CONFIG}" "${BOOTLOADER_UPDATE_IMAGE}"
--config "${NEW_EEPROM_CONFIG}" "${BOOTLOADER_UPDATE_IMAGE}"
fi
}
@@ -172,7 +188,7 @@ applyUpdate() {
prepareImage "${BOOTLOADER_UPDATE_IMAGE}"
echo "Applying bootloaer update ${BOOTLOADER_UPDATE_IMAGE}"
echo "Applying bootloader update ${BOOTLOADER_UPDATE_IMAGE}"
flashrom -p "linux_spi:dev=/dev/spidev0.0,spispeed=${SPI_SPEED}" -w "${TMP_EEPROM_IMAGE}" || die "flashrom EEPROM update failed"
dtparam -R spi-gpio40-45
@@ -224,24 +240,31 @@ 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
BOARD_REVISION="$(sed -n '/^Revision/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo)"
if [ $(((0x$BOARD_REVISION >> 23) & 1)) -ne 0 ] && [ $(((0x$BOARD_REVISION >> 12) & 15)) -eq 3 ]; then
echo "BCM2711 detected"
else
# Not a BCM2711, no EEPROMs to update.
exit ${EXIT_SUCCESS}
fi
if ! command -v vcgencmd > /dev/null; then
die "vcgencmd not found. On Debian, try installing the libraspberrypi-bin package."
fi
if [ ! -d "${FIRMWARE_IMAGE_DIR}" ]; then
die "EEPROM updates directory ${FIRMWARE_IMAGE_DIR} not found."
fi
# If a board revision specific firmware directory is defined then use that
# in preference to the generic directory.
if [ -d "${FIRMWARE_IMAGE_DIR}-${BOARD_REVISION}" ]; then
FIRMWARE_IMAGE_DIR="${FIRMWARE_IMAGE_DIR}-${BOARD_REVISION}"
fi
if ! command -v vl805 > /dev/null; then
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
die "vcgencmd: 'bootloader_config' command not supported. Please update VC firmware and reboot."
@@ -275,34 +298,30 @@ checkDependencies() {
usage() {
cat <<EOF
rpi-eeprom-update [options]... [FILE]
Checks whether the Raspberry Pi bootloader and the VL805 USB controller
EEPROMs are up-to-date and optionally updates the EEPROMs at the next reboot.
The default update mechanism writes recovery.bin and the EEPROM update
image(s) (pieeprom.upd and vl805.bin) to the boot partition on the sd-card.
The SHA256 hash of the corresponding images are written to pieeprom.sig
and/or vl805.sig. This guards against file system corruption which could
cause the EEPROM to be flashed with an invalid image. This is not a
security check.
Checks whether the Raspberry Pi bootloader and the VL805 USB controller
EEPROMs are up-to-date and optionally updates the EEPROMs at the next reboot.
At the next reboot the ROM runs recovery.bin which updates EEPROM(s).
If the update was successful recovery.bin renames itself to recovery.000
to prevent it from running a second time then resets the system.
The system should then boot normally.
The default update mechanism writes recovery.bin and the EEPROM update
image(s) (pieeprom.upd and vl805.bin) to the boot partition on the sd-card.
The SHA256 hash of the corresponding images are written to pieeprom.sig
and/or vl805.sig. This guards against file system corruption which could
cause the EEPROM to be flashed with an invalid image. This is not a
security check.
If /boot does not correspond to the boot partition on the sd-card and this
is not a NOOBS system then the mount point for BOOTFS should be defined
in /etc/default/rpi-eeprom-update by defining the BOOTFS variable.
At the next reboot the ROM runs recovery.bin which updates EEPROM(s).
If the update was successful recovery.bin renames itself to recovery.000
to prevent it from running a second time then resets the system.
The system should then boot normally.
For reference, the flashrom update mechanism may be enabled by defining
USE_FLASHROM=1 in /etc/default/rpi-eeprom-update. This not recommended
because the SPI pins are muxed with audio and other device drivers may
be using SPI (e.g. HATs). This is also not safe in the event of a power
failure during the update of the EEPROM.
If /boot does not correspond to the boot partition on the sd-card and this
is not a NOOBS system then the mount point for BOOTFS should be defined
in /etc/default/rpi-eeprom-update by defining the BOOTFS variable.
A backup of the current EEPROM config file is written to ${FIRMWARE_BACKUP_DIR}
before applying the update.
A backup of the current EEPROM config file is written to ${FIRMWARE_BACKUP_DIR}
before applying the update.
Options:
-a Automatically install bootloader and USB (VLI) EEPROM updates.
-A Specify which type of EEPROM to automatically update (vl805 or bootloader)
-d Use the default bootloader config instead of migrating the current settings
@@ -318,20 +337,53 @@ rpi-eeprom-update [options]... [FILE]
-r Removes temporary EEPROM update files from the boot partition.
-u Install the specified VL805 (USB EEPROM) image file.
To extract the configuration file from an EEPROM image:
Environment:
Environment variables should be defined in /etc/default/rpi-eeprom-update
EEPROM_CONFIG_HOOK
Specifies the path of an optional script which post-processes the
configuration file before it is applied to the new image. The modified
output must contain at least 3 lines and should contain WAKE_ON_GPIO
and POWER_OFF_ON_HALT settings.
USE_FLASHROM
The flashrom update mechanism may be enabled by setting USE_FLASHROM=1. This
also selects the vl805 tool instead of using recovery.bin to perform the
update. This may be desirable if an immediate update is required or if an
sd-card is not present.
However, this not recommended because the SPI pins are muxed with audio and other
device drivers may be using SPI (e.g. HATs). This is also not safe in the
event of a power failure during the update of the EEPROM.
Changing the VL805 firmware whilst USB devices are attached may also cause
those devices to stop working until after the system is reboot.
FIRMWARE_RELEASE_STATUS
Specifies the release status of the firmware to apply. The default is 'critical'
which is the most stable production version. Alternatively, 'beta' may be selected
for development releases.
A 'critical' update is the latest stable production version and is normally
only updated after it has been tested via the 'beta' release.
Before selecting a firmware release directory this script checks whether there
is a board revision specific variant e.g. critical-c03111. If present then the
board-revision specific version is used in preference.
Examples:
To extract the configuration file from an EEPROM image:
rpi-eeprom-config pieeprom.bin --out bootconf.txt
To update the configuration file in an EEPROM image:
To update the configuration file in an EEPROM image:
rpi-eeprom-config pieeprom.bin --config bootconf.txt --out pieeprom-new.bin
To flash the new image:
To flash the new image:
sudo rpi-eeprom-update -d -f ./pieeprom-new.bin
The syntax is the same as config.txt but section filters etc are not supported. See
online documentation for the list of parameters.
The syntax is the same as config.txt See online documentation for the list of parameters.
The official documentation for the Raspberry Pi bootloader EEPROM is available at
https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md
The official documentation for the Raspberry Pi bootloader EEPROM is available at
https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md
EOF
exit ${EXIT_SUCCESS}
@@ -401,19 +453,17 @@ getVL805CurrentVersion()
getVL805UpdateVersion()
{
# The latest VL805 version is indicated by a file containing the version
# number. If the version file exists then verify that the corresponding
# VL805 binary exists before selecting it.
# There are no user modifiable sections in the VL805 firmware and there
# are unlikely to be many updates to it so just indicate the latest supported
# version. This also avoids making any assumptions about the VLI version numbers.
# The VL805 version number is an eight character hex string. Select the
# largest number for the newest version.
# The vl805.latest version is retained for backwards compatibility with
# thirdparty scripts (are there any?) but it not used by this script and
# is deprecated.
VL805_UPDATE_VERSION=""
if [ -f "${FIRMWARE_IMAGE_DIR}/vl805.latest" ]; then
ver="$(cat "${FIRMWARE_IMAGE_DIR}/vl805.latest")"
if [ -f "${FIRMWARE_IMAGE_DIR}/vl805-${ver}.bin" ]; then
VL805_UPDATE_VERSION="${ver}"
VL805_UPDATE_IMAGE="${FIRMWARE_IMAGE_DIR}/vl805-${ver}.bin"
fi
match='.*/vl805-.*.bin'
ver=$(find "${FIRMWARE_IMAGE_DIR}" -maxdepth 1 -type f -follow -regex "${match}" | sed 's/.*\/vl805-\([0-9a-f]*\)\.bin/\1/' | sort -r | head -n1)
if [ -f "${FIRMWARE_IMAGE_DIR}/vl805-${ver}.bin" ]; then
VL805_UPDATE_VERSION="${ver}"
VL805_UPDATE_IMAGE="${FIRMWARE_IMAGE_DIR}/vl805-${ver}.bin"
fi
}
@@ -434,7 +484,7 @@ lookupVersionInfo()
fi
if [ -n "${VL805_CURRENT_VERSION}" ] && [ -n "${VL805_UPDATE_VERSION}" ]; then
if [ "${VL805_CURRENT_VERSION}" != "${VL805_UPDATE_VERSION}" ]; then
if [ "${VL805_CURRENT_VERSION}" \< "${VL805_UPDATE_VERSION}" ]; then
ACTION_UPDATE_VL805=1
else
VL805_UPDATE_IMAGE=""
@@ -496,7 +546,7 @@ removePreviousUpdates()
rm -f "${BOOTFS}/pieeprom.bin" "${BOOTFS}/pieeprom.upd" "${BOOTFS}/pieeprom.sig"
rm -f "${BOOTFS}/vl805.bin" "${BOOTFS}/vl805.sig"
# Case insensitive for FAT bootfs
find "${BOOTFS}" -maxdepth 1 -type f -iname "recovery.*" -regex '.*\.[0-9][0-9][0-9]$' -exec rm -f {} \;
find "${BOOTFS}" -maxdepth 1 -type f -follow -iname "recovery.*" -regex '.*\.[0-9][0-9][0-9]$' -exec rm -f {} \;
fi
}

View File

@@ -5,3 +5,4 @@ FIRMWARE_IMAGE_DIR="${FIRMWARE_ROOT}/${FIRMWARE_RELEASE_STATUS}"
FIRMWARE_BACKUP_DIR="/var/lib/raspberrypi/bootloader/backup"
BOOTFS=/boot
USE_FLASHROM=0
EEPROM_CONFIG_HOOK=

View File

@@ -22,7 +22,7 @@ CONFIG="/etc/default/rpi-eeprom-update"
cp -rfv "${FIRMWARE_DIR}"/* /lib/firmware/raspberrypi/bootloader
cp -fv "${script_dir}/../rpi-eeprom-config" /usr/bin
cp -fv "${script_dir}/../rpi-eeprom-update" /usr/bin
cp -fv "${script_dir}/../vl805" /usr/bin
cp -fv "${script_dir}/../firmware/vl805" /usr/bin
cp -fv "${script_dir}/../rpi-eeprom-update-default" /etc/default/rpi-eeprom-update