From a6e6f88848a9e4b40cbd57271ac14703c056f86b Mon Sep 17 00:00:00 2001 From: timg <990920+timg236@users.noreply.github.com> Date: Mon, 23 Sep 2019 15:27:02 +0100 Subject: [PATCH 1/4] Update raspberry_pi4_network_boot_beta.md --- firmware/raspberry_pi4_network_boot_beta.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/raspberry_pi4_network_boot_beta.md b/firmware/raspberry_pi4_network_boot_beta.md index 77d1222..3078afc 100644 --- a/firmware/raspberry_pi4_network_boot_beta.md +++ b/firmware/raspberry_pi4_network_boot_beta.md @@ -43,7 +43,7 @@ sudo echo FIRMWARE_RELEASE_STATUS="beta" > /etc/default/rpi-eeprom-update Network boot is not enabled by default in the bootloader. To enable it the bootloader configuration file must be edited. ``` # Extract the configuration file -cp /lib/firmware/raspberrypi/beta/pieeprom-2019-09-23.bin pieeprom.bin +cp /lib/firmware/raspberrypi/bootloader/beta/pieeprom-2019-09-23.bin pieeprom.bin rpi-eeprom-config pieeprom.bin > bootconf.txt # Enable network boot From 33974463a1567959015250bf7b94590271f30f21 Mon Sep 17 00:00:00 2001 From: timg <990920+timg236@users.noreply.github.com> Date: Mon, 23 Sep 2019 16:50:31 +0100 Subject: [PATCH 2/4] Update raspberry_pi4_network_boot_beta.md --- firmware/raspberry_pi4_network_boot_beta.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/raspberry_pi4_network_boot_beta.md b/firmware/raspberry_pi4_network_boot_beta.md index 3078afc..c0b51a8 100644 --- a/firmware/raspberry_pi4_network_boot_beta.md +++ b/firmware/raspberry_pi4_network_boot_beta.md @@ -14,7 +14,8 @@ This documentation will be merged into the main bootloader documents after the b Network boot requires a TFTP and NFS server to be configured. See [Network boot server tutorial](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/net_tutorial.md) Additional notes:- -* The VideoCore firmware (start4.elf) must be updated to the latest rpi-update version in order to get the Pi4 network drivers. +* The VideoCore firmware (start4.elf and fixup4.dat) must be updated to the latest rpi-update version in order to get the Pi4 network drivers. +* The latest VideoCore firmware can be downloaded directly from the [rpi-update GitHub repo](https://github.com/Hexxeh/rpi-update) * The MAC address on the Pi4 is programmed at manufacture and is not derived from the serial number. ``` From 1ba58068eaacc4d31c0a150e8561889ce4e16f03 Mon Sep 17 00:00:00 2001 From: Tim Gover Date: Tue, 24 Sep 2019 13:10:24 +0100 Subject: [PATCH 3/4] Set unused data to zero if size of config is reduced If the size of bootconf.txt is reduced then set the unused data to all ones instead of leaving garbage at the end. The EEPROM header contains the actual file but this makes it easier to verify the image and makes overreads more obvious. --- rpi-eeprom-config | 9 +++++++ test/test-rpi-eeprom-config | 49 +++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/rpi-eeprom-config b/rpi-eeprom-config index ee39da2..993793f 100755 --- a/rpi-eeprom-config +++ b/rpi-eeprom-config @@ -62,6 +62,15 @@ class BootloaderImage(object): struct.pack_into('>L', self._bytes, hdr_offset + 4, new_len) struct.pack_into(("%ds" % len(new_config_bytes)), self._bytes, hdr_offset + 4 + FILE_HDR_LEN, new_config_bytes) + + # If the new config is smaller than the old config then set any old + # data which is now unused to all ones (erase value) + pad_start = hdr_offset + 4 + FILE_HDR_LEN + len(new_config_bytes) + pad = 0 + while pad < (length - len(new_config_bytes)): + struct.pack_into('B', self._bytes, pad_start + pad, 0xff) + pad = pad + 1 + if self._out is not None: self._out.write(self._bytes) self._out.close() diff --git a/test/test-rpi-eeprom-config b/test/test-rpi-eeprom-config index 309b991..9d72068 100755 --- a/test/test-rpi-eeprom-config +++ b/test/test-rpi-eeprom-config @@ -4,19 +4,61 @@ set -e script_dir="$(cd "$(dirname "$0")" && pwd)" die() { + echo "ERROR" echo "$@" >&2 exit 1 } TMP_CONFIG="" TMP_EEPROM="" +TMP_EEPROM2="" cleanup() { - rm -f "${TMP_CONFIG}" -f "${TMP_EEPROM}" + rm -f "${TMP_CONFIG}" -f "${TMP_EEPROM}" "${TMP_EEPROM2}" TMP_CONFIG="" TMP_EEPROM="" + TMP_EEPROM2="" } trap cleanup EXIT +check_reduce_size() +{ + # Verify that unused bytes are set to 0xff if the size of the config file is reduced. + echo "check_update $1 $2" + + image="${script_dir}/$1" + conf="${script_dir}/$2" + + # Check that the production config file can be read correctly + image_md5="$(md5sum "${image}" | awk '{print $1}')" + TMP_CONFIG="$(mktemp)" + + # Generate a new EEPROM with larger config file + cp -f "${conf}" "${TMP_CONFIG}" + echo "Add some random text to the config file" >> "${TMP_CONFIG}" + + TMP_EEPROM="$(mktemp)" + "${script_dir}/../rpi-eeprom-config" \ + "${image}" \ + --config "${TMP_CONFIG}" \ + --out "${TMP_EEPROM}" + + # Check that the new image is different + actual_md5="$(md5sum "${TMP_EEPROM}" | awk '{print $1}')" + [ "${image_md5}" != "${actual_md5}" ] || die "EEPROM images should be different" + + # Re-apply the original configuration and make sure the image is the same + TMP_EEPROM2="$(mktemp)" + "${script_dir}/../rpi-eeprom-config" \ + "${TMP_EEPROM}" \ + --config "${conf}" \ + --out "${TMP_EEPROM2}" + + # Check that applying the EEPROM config file again gets back to the original image + actual_md5="$(md5sum "${TMP_EEPROM2}" | awk '{print $1}')" + [ "${image_md5}" = "${actual_md5}" ] || die "Image should be the same as original" + +} + check_loopback() { echo "check_update $1 $2" @@ -30,7 +72,7 @@ check_loopback() [ "${actual_md5}" = "${expected_md5}" ] || die "Config-read: checksum mismatch" # Check that overwriting the config section produces an identical binary - TMP_EEPROM=$(mktemp) + TMP_EEPROM="$(mktemp)" "${script_dir}/../rpi-eeprom-config" \ "${image}" \ --config "${conf}" \ @@ -73,3 +115,6 @@ cleanup check_update "../firmware/critical/pieeprom-2019-07-15.bin" "pieeprom-2019-07-15-freeze.bin" "bootconf-2019-07-15-freeze.txt" cleanup + +check_reduce_size "../firmware/critical/pieeprom-2019-05-10.bin" "bootconf-2019-05-10.txt" +cleanup From 52f02d17de4eb6e903fb28b808929a0674ac166a Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Tue, 24 Sep 2019 15:39:53 +0100 Subject: [PATCH 4/4] 1.2-1 release --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index 265af9b..ff9c0c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +rpi-eeprom (1.2-1) buster; urgency=medium + + [ Tim Gover ] + * Update raspberry_pi4_network_boot_beta.md + * Set unused data to zero if size of config is reduced + + -- Serge Schneider Tue, 24 Sep 2019 15:39:28 +0100 + rpi-eeprom (1.1-1) buster; urgency=medium [ Tim Gover ]