Merge pull request #16 from XECDesign/debian/buster

Debian/buster
This commit is contained in:
timg
2019-09-18 12:19:02 +01:00
committed by GitHub
13 changed files with 168 additions and 33 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.swp

23
debian/changelog vendored
View File

@@ -1,3 +1,26 @@
rpi-eeprom (1.0-1) buster; urgency=medium
[ Tim Gover ]
* Fix magic number check
* Add .gitignore
* Add unit test for rpi-eeprom-config
* recovery.bin: Update to fix rename bug with FAT16
* Bump pieeprom-2019-09-10 to stable
[ andrum99 ]
* rpi-eeprom-update: minor fixes to usage
* fix quotation mark
* getLatestCriticalUpdate -> getUpdateVersion
* fix comment
* fix call to getUpdateVersion
* add colons to usage
* usage: critical -> applicable
[ Serge Schneider ]
* Update gbp.conf
-- Serge Schneider <serge@raspberrypi.org> Wed, 18 Sep 2019 11:18:06 +0100
rpi-eeprom (0.3-1) buster; urgency=medium rpi-eeprom (0.3-1) buster; urgency=medium
* rpi-eeprom-update: Fix CPU detection and improve documentation * rpi-eeprom-update: Fix CPU detection and improve documentation

2
debian/gbp.conf vendored
View File

@@ -1,3 +1,3 @@
[buildpackage] [DEFAULT]
upstream-tree = master upstream-tree = master
debian-branch = debian/buster debian-branch = debian/buster

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,6 @@
# Raspberry Pi4 bootloader EEPROM release notes # Raspberry Pi4 bootloader EEPROM release notes
## 2019-09-10 - Git f626c772 - (BETA) ## 2019-09-10 - Git f626c772
* Configure ethernet RGMII pins at power on. This is a minor change which * Configure ethernet RGMII pins at power on. This is a minor change which
which may improve reliability of ethernet for some users. which may improve reliability of ethernet for some users.

View File

@@ -15,7 +15,8 @@ IMAGE_SIZE = 512 * 1024
# The number, order and size of the sections depends on the bootloader version # The number, order and size of the sections depends on the bootloader version
# but the following mask can be used to test for section headers and skip # but the following mask can be used to test for section headers and skip
# unknown data. # unknown data.
MAGIC_MASK = 0x55aaf00f MAGIC = 0x55aaf00f
MAGIC_MASK = 0xfffff00f
FILE_MAGIC = 0x55aaf11f # id for modifiable file, currently only bootconf.txt FILE_MAGIC = 0x55aaf11f # id for modifiable file, currently only bootconf.txt
FILE_HDR_LEN = 20 FILE_HDR_LEN = 20
FILENAME_LEN = 12 FILENAME_LEN = 12
@@ -37,7 +38,7 @@ class BootloaderImage(object):
magic = 0 magic = 0
while offset < IMAGE_SIZE: while offset < IMAGE_SIZE:
magic, length = struct.unpack_from('>LL', self._bytes, offset) magic, length = struct.unpack_from('>LL', self._bytes, offset)
if (magic & MAGIC_MASK) != MAGIC_MASK: if (magic & MAGIC_MASK) != MAGIC:
raise Exception('EEPROM is corrupted') raise Exception('EEPROM is corrupted')
if magic == FILE_MAGIC: # Found a file if magic == FILE_MAGIC: # Found a file

View File

@@ -167,16 +167,16 @@ getCurrentVersion() {
fi fi
} }
# Set to the latest critical firmware version # Find latest applicable update version
CRITICAL_UPDATE_IMAGE="" UPDATE_IMAGE=""
CRITICAL_UPDATE_VERSION=0 UPDATE_VERSION=0
getLatestCriticalUpdate() { getUpdateVersion() {
CRITICAL_UPDATE_VERSION=0 UPDATE_VERSION=0
match=".*/pieeprom-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].bin" match=".*/pieeprom-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].bin"
latest="$(find "${FIRMWARE_IMAGE_DIR}" -maxdepth 1 -type f -size "${EEPROM_SIZE}c" -regex "${match}" | sort -r | head -n1)" latest="$(find "${FIRMWARE_IMAGE_DIR}" -maxdepth 1 -type f -size "${EEPROM_SIZE}c" -regex "${match}" | sort -r | head -n1)"
if [ -f "${latest}" ]; then if [ -f "${latest}" ]; then
CRITICAL_UPDATE_VERSION=$(strings "${latest}" | grep BUILD_TIMESTAMP | sed 's/.*=//g') UPDATE_VERSION=$(strings "${latest}" | grep BUILD_TIMESTAMP | sed 's/.*=//g')
CRITICAL_UPDATE_IMAGE="${latest}" UPDATE_IMAGE="${latest}"
fi fi
} }
@@ -189,11 +189,11 @@ checkDependencies() {
fi fi
if [ ! -d "${FIRMWARE_IMAGE_DIR}" ]; then if [ ! -d "${FIRMWARE_IMAGE_DIR}" ]; then
die "Bootloader critical updates directory ${FIRMWARE_IMAGE_DIR} not found." die "Bootloader updates directory ${FIRMWARE_IMAGE_DIR} not found."
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. not supported. Please update VC firmware" die "vcgencmd: 'bootloader_config' command not supported. Please update VC firmware"
fi fi
if ! flashrom --version > /dev/null 2>&1; then if ! flashrom --version > /dev/null 2>&1; then
@@ -201,14 +201,14 @@ checkDependencies() {
fi fi
if [ "${USE_FLASHROM}" = 0 ]; then if [ "${USE_FLASHROM}" = 0 ]; then
[ -f "${RECOVERY_BIN}" ] || die "${RECOVERY_BIN} not found" [ -f "${RECOVERY_BIN}" ] || die "${RECOVERY_BIN} not found."
fi fi
} }
usage() { usage() {
cat <<EOF cat <<EOF
rpi-eeprom-update [options]... [FILE] rpi-eeprom-update [options]... [FILE]
Checks whether there Raspberry Pi bootloader EEPROM is up to date and Checks whether the Raspberry Pi bootloader EEPROM is up-to-date and
optionally updates the EEPROM at the next reboot. optionally updates the EEPROM at the next reboot.
The default update mechanism writes recovery.bin and pieeprom.upd to the The default update mechanism writes recovery.bin and pieeprom.upd to the
@@ -230,9 +230,9 @@ rpi-eeprom-update [options]... [FILE]
A backup of the current EEPROM config file is written to ${FIRMWARE_BACKUP_DIR} A backup of the current EEPROM config file is written to ${FIRMWARE_BACKUP_DIR}
before applying the update. before applying the update.
-a Install the latest critical update if necessary. -a Install the latest update if necessary
-d Use the default bootloader config instead of migrating the current settings. -d Use the default bootloader config instead of migrating the current settings
-f Install the given file instead of the latest critical update. -f Install the given file instead of the latest applicable update
Ignores the FREEZE_VERSION flag in bootloader and is intended for manual Ignores the FREEZE_VERSION flag in bootloader and is intended for manual
firmware updates. firmware updates.
WARNING: This command should only be run from console mode in order to WARNING: This command should only be run from console mode in order to
@@ -241,19 +241,20 @@ rpi-eeprom-update [options]... [FILE]
-j Write status information using JSON notation -j Write status information using JSON notation
-m Write status information to the given file when run without -a or -f -m Write status information to the given file when run without -a or -f
To extract the configuration file from an EEPROM image.
To extract the configuration file from an EEPROM image:
rpi-eeprom-config pieeprom.bin --out bootconf.txt 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 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 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 The syntax is the same as config.txt but section filters etc are not supported. See
online documentation for the list of paramters. online documentation for the list of parameters.
The official documentation for the Raspberry Pi bootloader EEPROM is available here:- The official documentation for the Raspberry Pi bootloader EEPROM is available at
https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md
EOF EOF
@@ -292,12 +293,12 @@ findBootFS()
checkAndApply() checkAndApply()
{ {
getCurrentVersion getCurrentVersion
getLatestCriticalUpdate getUpdateVersion
if [ "${CRITICAL_UPDATE_VERSION}" -gt "${CURRENT_VERSION}" ]; then if [ "${UPDATE_VERSION}" -gt "${CURRENT_VERSION}" ]; then
printVersions "${CURRENT_VERSION}" "${CRITICAL_UPDATE_VERSION}" printVersions "${CURRENT_VERSION}" "${UPDATE_VERSION}"
echo "*** INSTALLING REQUIRED UPDATE ***" echo "*** INSTALLING REQUIRED UPDATE ***"
applyUpdate "${CRITICAL_UPDATE_IMAGE}" applyUpdate "${UPDATE_IMAGE}"
echo "Bootloader EEPROM update pending. Please reboot to apply the update." echo "Bootloader EEPROM update pending. Please reboot to apply the update."
else else
echo "Bootloader EEPROM is up to date. $(date -d@${CURRENT_VERSION})" echo "Bootloader EEPROM is up to date. $(date -d@${CURRENT_VERSION})"
@@ -330,16 +331,16 @@ removePreviousUpdates()
checkVersion() checkVersion()
{ {
getCurrentVersion getCurrentVersion
getLatestCriticalUpdate getUpdateVersion
if [ "${CRITICAL_UPDATE_VERSION}" -gt "${CURRENT_VERSION}" ]; then if [ "${UPDATE_VERSION}" -gt "${CURRENT_VERSION}" ]; then
echo "*** UPDATE REQUIRED ***" echo "*** UPDATE REQUIRED ***"
printVersions "${CURRENT_VERSION}" "${CRITICAL_UPDATE_VERSION}" printVersions "${CURRENT_VERSION}" "${UPDATE_VERSION}"
write_status_info EXIT_UPDATE_REQUIRED "${CURRENT_VERSION}" "${CRITICAL_UPDATE_VERSION}" write_status_info EXIT_UPDATE_REQUIRED "${CURRENT_VERSION}" "${UPDATE_VERSION}"
exit ${EXIT_UPDATE_REQUIRED} exit ${EXIT_UPDATE_REQUIRED}
else else
echo "Bootloader EEPROM is up to date" echo "Bootloader EEPROM is up to date"
printVersions "${CURRENT_VERSION}" "${CRITICAL_UPDATE_VERSION}" printVersions "${CURRENT_VERSION}" "${UPDATE_VERSION}"
write_status_info EXIT_SUCCESS "${CURRENT_VERSION}" "${CRITICAL_UPDATE_VERSION}" write_status_info EXIT_SUCCESS "${CURRENT_VERSION}" "${UPDATE_VERSION}"
exit ${EXIT_SUCCESS} exit ${EXIT_SUCCESS}
fi fi
} }

View File

@@ -0,0 +1,2 @@
BOOT_UART=0
WAKE_ON_GPIO=0

View File

@@ -0,0 +1,16 @@
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
FREEZE_VERSION=1

View File

@@ -0,0 +1,16 @@
BOOT_UART=0
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0

Binary file not shown.

75
test/test-rpi-eeprom-config Executable file
View File

@@ -0,0 +1,75 @@
#!/bin/sh
set -e
script_dir="$(cd "$(dirname "$0")" && pwd)"
die() {
echo "$@" >&2
exit 1
}
TMP_CONFIG=""
TMP_EEPROM=""
cleanup() {
rm -f "${TMP_CONFIG}" -f "${TMP_EEPROM}"
TMP_CONFIG=""
TMP_EEPROM=""
}
trap cleanup EXIT
check_loopback()
{
echo "check_update $1 $2"
image="${script_dir}/$1"
conf="${script_dir}/$2"
# Check that the production config file can be read correctly
expected_md5="$(md5sum "${conf}" | awk '{print $1}')"
actual_md5="$("${script_dir}/../rpi-eeprom-config" "${image}" | md5sum | awk '{print $1}')"
[ "${actual_md5}" = "${expected_md5}" ] || die "Config-read: checksum mismatch"
# Check that overwriting the config section produces an identical binary
TMP_EEPROM=$(mktemp)
"${script_dir}/../rpi-eeprom-config" \
"${image}" \
--config "${conf}" \
--out "${TMP_EEPROM}"
expected_md5="$(md5sum "${image}" | awk '{print $1}')"
actual_md5="$(md5sum "${TMP_EEPROM}" | awk '{print $1}')"
[ "${actual_md5}" = "${expected_md5}" ] || die "EEPROM loopback: checksum mismatch"
}
# Update the EEPROM with a new config and check the expected image is produced
check_update()
{
echo "check_update $1 $2 $3"
image="${script_dir}/$1"
ref_image="${script_dir}/$2"
conf="${script_dir}/$3"
expected_md5="$(md5sum "${ref_image}" | awk '{print $1}')"
TMP_EEPROM="$(mktemp)"
"${script_dir}/../rpi-eeprom-config" \
"${image}" \
--config "${conf}" \
--out "${TMP_EEPROM}"
actual_md5="$(md5sum "${TMP_EEPROM}" | awk '{print $1}')"
if [ "${actual_md5}" != "${expected_md5}" ]; then
hexdump -C "${TMP_EEPROM}" > "tmp.hex"
die "EEPROM update: checksum mismatch"
fi
}
check_loopback "../firmware/critical/pieeprom-2019-05-10.bin" "bootconf-2019-05-10.txt"
cleanup
check_loopback "../firmware/critical/pieeprom-2019-07-15.bin" "bootconf-2019-07-15.txt"
cleanup
check_update "../firmware/critical/pieeprom-2019-07-15.bin" "pieeprom-2019-07-15-freeze.bin" "bootconf-2019-07-15-freeze.txt"
cleanup