Skip to content

Commit

Permalink
imager-release: Update for Pi5
Browse files Browse the repository at this point in the history
  • Loading branch information
timg236 committed Oct 19, 2023
1 parent a9d76cf commit f13b578
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 41 deletions.
2 changes: 1 addition & 1 deletion imager/README.txt → imager/README-2711.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Raspberry Pi 4 EEPROM bootloader rescue image
Raspberry Pi 4 EEPROM bootloader recovery image
*********************************************

The Raspberry Pi 4 contains a small EEPROM used to store the bootloader.
Expand Down
33 changes: 33 additions & 0 deletions imager/README-2712.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Raspberry Pi 5 EEPROM bootloader recovery image
***********************************************

The Raspberry Pi 5 contains a small EEPROM used to store the bootloader.

This rescue image reverts the bootloader EEPROM to factory default settings.

The easiest method for creating EEPROM rescue images, and formatting SD
cards, is to use Raspberry Pi Imager from https://raspberrypi.com/software.
Raspberry Pi Imager provides a GUI for downloading the latest version of
this rescue image and flashing it to a spare SD card.

Alternatively, copy the contents of this zip file to a blank
FAT formatted SD card. The FAT partition must be < 32 GB.

To update the EEPROM:

1. Power off the Raspberry Pi
2. Insert the bootloader update SD card
3. Power on the Raspberry Pi
4. Wait at least 10 seconds

If successful, the green LED on the Raspberry Pi will blink rapidly forever.
An unsuccessful update of the EEPROM is indicated by a different blinking
pattern corresponding to the specific error.

If an HDMI display is attached, then the screen will display green for
success or red if a failure occurs.

Once the EEPROM is updated, the SD card can be removed. In order to make
the entire capacity of the SD card available again, you must then reformat
the SD card using Raspberry Pi Imager by selecting the 'format card as
FAT32' option.
2 changes: 1 addition & 1 deletion imager/make-imager-release
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ script_dir=$(cd "$(dirname "$0")" && pwd)
${script_dir}/make-release critical 2023-01-11 000138c0 "${script_dir}/2711-config" release-2711 rpi-boot-eeprom-recovery 2711

# Pi5
${script_dir}/make-release critical 2023-09-21 "" "${script_dir}/2712-config" release-2712 rpi-boot-eeprom-recovery 2712
${script_dir}/make-release critical 2023-10-18 "" "${script_dir}/2712-config" release-2712 rpi-boot-eeprom-recovery 2712
81 changes: 45 additions & 36 deletions imager/make-recovery-images
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,57 @@ trap cleanup EXIT
[ -n "${SUDO_UID}" ] || die "SUDO_UID not defined"
[ -n "${SUDO_GID}" ] || die "SUDO_GID not defined"

for src in release/*.zip; do
src=$(basename "${src}")
img=$(echo "${src}" | sed 's/\.zip/.img/')
TMP_DIR=$(mktemp -d)
(
cp "release/${src}" "${TMP_DIR}"
mkdir "${TMP_DIR}/files"
cd "${TMP_DIR}/files"
unzip "../${src}"
cd "${TMP_DIR}"
dd if=/dev/zero bs=1M count=258 of=temp.img
/sbin/sfdisk temp.img <<EOF
build_images()
{
chip="$1"
for src in release-${chip}/*.zip; do
src=$(basename "${src}")
img=$(echo "${src}" | sed 's/\.zip/.img/')
TMP_DIR=$(mktemp -d)
(
cp "release-${chip}/${src}" "${TMP_DIR}"
mkdir "${TMP_DIR}/files"
cd "${TMP_DIR}/files"
unzip "../${src}"
cd "${TMP_DIR}"
dd if=/dev/zero bs=1M count=258 of=temp.img
/sbin/sfdisk temp.img <<EOF
label: dos
label-id: 0x0a7b5ac5
device: temp.img
unit: sectors
./test.img1 : start= 2048, size= 524288, type=c
EOF
file temp.img
kpartx -lv temp.img | head -n1 | awk '{print $1}'
LOOP="/dev/mapper/$(kpartx -lv temp.img | head -n1 | awk '{print $1}')"
kpartx -av temp.img
/sbin/mkfs.fat -F 32 -s 1 "${LOOP}"
mkdir fs
mount "${LOOP}" fs
cp -v files/* fs
sync
sleep 5
umount fs
# Delay before calling kpartx otherwise it's sometimes possible to get orphaned loopback devices
sleep 5
kpartx -dv temp.img
)
mkdir -p images
chown "${SUDO_UID}:${SUDO_GID}" images
mv "${TMP_DIR}/temp.img" "images/${img}"
file "images/${img}"
cd images
file temp.img
kpartx -lv temp.img | head -n1 | awk '{print $1}'
LOOP="/dev/mapper/$(kpartx -lv temp.img | head -n1 | awk '{print $1}')"
kpartx -av temp.img
/sbin/mkfs.fat -F 32 -s 1 "${LOOP}"
mkdir fs
mount "${LOOP}" fs
cp -v files/* fs
sync
sleep 5
umount fs
# Delay before calling kpartx otherwise it's sometimes possible to get orphaned loopback devices
sleep 5
kpartx -dv temp.img
)
image_dir="images-${chip}"
mkdir -p "${image_dir}"
chown "${SUDO_UID}:${SUDO_GID}" "${image_dir}"
mv "${TMP_DIR}/temp.img" "${image_dir}/${img}"
file "${image_dir}/${img}"
cd "${image_dir}"
zip "${src}" "${img}"
cd ..
rm "images/${img}"
chown "${SUDO_UID}:${SUDO_GID}" "images/${src}"
done
echo "Wrote images for rpi-imager to $(pwd)/images/${src}"
rm "${image_dir}/${img}"
chown "${SUDO_UID}:${SUDO_GID}" "${image_dir}/${src}"
done
echo "Wrote images for rpi-imager to $(pwd)/${image_dir}/${src}"
}

build_images 2711
build_images 2712

6 changes: 3 additions & 3 deletions imager/make-release
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gen_release() {
(
tmp_dir="$(mktemp -d --tmpdir tmp.rpi-eeprom.XXXXXXXXXX)"
cd "${tmp_dir}"
cp "${script_dir}/README.txt" .
cp "${script_dir}/README-${bcm_chip}.txt" README.txt
cp "${firmware_dir}/recovery.bin" .
if [ ${bcm_chip} = 2711 ]; then
cp "${firmware_dir}/vl805-${vl805_version}.bin" vl805.bin
Expand Down Expand Up @@ -79,9 +79,9 @@ firmware_dir=${script_dir}/../firmware-${bcm_chip}/${firmware_status}
if [ "${bcm_chip}" = 2711 ]; then
[ -f "${firmware_dir}/vl805-${vl805_version}.bin" ] || (echo "${firmware_status}/vl805-${vl805_version}.bin doesn't exist" && exit 1)
[ -d "${config_dir}" ] || (echo "${config_dir} doesn't exist" && exit 1)
tag="${pieeprom_version}-vl805-${vl805_version}"
tag="${pieeprom_version}-${bcm_chip}-vl805-${vl805_version}"
else
tag="${pieeprom_version}"
tag="${pieeprom_version}-${bcm_chip}"
fi
# use realpath to ensure paths are absolute
config_dir=$(realpath "${config_dir}")
Expand Down

0 comments on commit f13b578

Please sign in to comment.