-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3803 from MilhouseVH/le92_rpi4_firmware
RPi4: add tools for updating SPI bootloader [backport]
- Loading branch information
Showing
13 changed files
with
189 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
|
||
# SPDX-License-Identifier: GPL-2.0 | ||
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv) | ||
|
||
FLAG_FILE="/storage/.rpi_flash_firmware" | ||
|
||
. /usr/lib/libreelec/functions | ||
|
||
hidecursor | ||
|
||
if ! mount -o remount,rw /flash 2>/dev/null; then | ||
# Remove flag file and bail out | ||
rm -f "${FLAG_FILE}" | ||
sync | ||
|
||
echo "ERROR: Unable to mount /flash as a read/write file system." | ||
echo | ||
echo "Aborting Flash update process - please proceed with a manual update." | ||
echo | ||
|
||
StartProgress countdown "Rebooting in 15s... " 15 "NOW" | ||
fi | ||
|
||
if [ -f "${FLAG_FILE}" ]; then | ||
. ${FLAG_FILE} | ||
|
||
# Prepare flashing environment | ||
if [ "${MODE}" = "init" ]; then | ||
# Install new SPI bootloader files to /flash (if required) | ||
if [ "${BOOTLOADER}" = "yes" ]; then | ||
USE_FLASHROM=0 /usr/bin/.rpi-eeprom-update.real -a | ||
fi | ||
|
||
# Bump process to next step | ||
sed -e 's/^MODE=.*/MODE="update"/' -i "${FLAG_FILE}" | ||
sync | ||
else | ||
rm -f "${FLAG_FILE}" | ||
sync | ||
|
||
if [ "${MODE}" = "update" ]; then | ||
# Display current bootloader status | ||
if [ "${BOOTLOADER}" = "yes" ]; then | ||
USE_FLASHROM=0 /usr/bin/.rpi-eeprom-update.real | ||
fi | ||
|
||
# Apply VIA USB3 update | ||
# if [ "${USB3}" = "yes" ]; then | ||
# /usr/bin/vl805 | ||
# fi | ||
|
||
sync | ||
echo "" | ||
StartProgress countdown "Rebooting in 15s... " 15 "NOW" | ||
fi | ||
fi | ||
|
||
sync | ||
mount -o remount,ro /flash | ||
fi | ||
|
||
reboot -f &>/dev/null |
12 changes: 12 additions & 0 deletions
12
packages/sysutils/busybox/system.d/rpi-flash-firmware.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=RPi Flash Firmware | ||
Requires=tmp.mount var.mount sys-kernel-config.mount kernel-overlays.service | ||
After=tmp.mount var.mount sys-kernel-config.mount kernel-overlays.service | ||
DefaultDependencies=no | ||
|
||
[Service] | ||
Type=idle | ||
ExecStart=/usr/lib/libreelec/rpi-flash-firmware | ||
StandardInput=tty-force | ||
StandardOutput=inherit | ||
StandardError=inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[Unit] | ||
Description=RPi Flash Firmware target | ||
Requires=rpi-flash-firmware.service | ||
After=rpi-flash-firmware.service | ||
AllowIsolate=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# Copyright (C) 2019 Team LibreELEC (https://libreelec.tv) | ||
|
||
PKG_NAME="flashrom" | ||
PKG_VERSION="1.1" | ||
PKG_SHA256="aeada9c70c22421217c669356180c0deddd0b60876e63d2224e3260b90c14e19" | ||
PKG_LICENSE="GPL" | ||
PKG_SITE="https://www.flashrom.org/Flashrom" | ||
PKG_URL="https://download.flashrom.org/releases/${PKG_NAME}-v${PKG_VERSION}.tar.bz2" | ||
PKG_DEPENDS_TARGET="toolchain libusb-compat" | ||
PKG_LONGDESC="flashrom is a utility for identifying, reading, writing, verifying and erasing flash chips. It is designed to flash BIOS/EFI/coreboot/firmware/optionROM images on mainboards, network/graphics/storage controller cards, and various other programmer devices." | ||
|
||
PKG_MAKE_OPTS_TARGET="PREFIX=/usr \ | ||
CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no \ | ||
CONFIG_FT2232_SPI=no \ | ||
CONFIG_USBBLASTER_SPI=no \ | ||
CONFIG_JLINK_SPI=no" | ||
PKG_MAKEINSTALL_OPTS_TARGET="${PKG_MAKE_OPTS_TARGET}" | ||
|
||
post_makeinstall_target() { | ||
rm -fr ${INSTALL}/usr/share/man | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Use direct path to firmware as update script doesn't dereference sym links. | ||
FIRMWARE_ROOT="/usr/lib/kernel-overlays/base/lib/firmware/raspberrypi/bootloader" | ||
FIRMWARE_BACKUP_DIR="/storage/.config/rpifw-backup" | ||
BOOTFS=/flash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv) | ||
|
||
PKG_NAME="rpi-eeprom" | ||
PKG_VERSION="1923a55d0e4629becf50b834a83b86e6d5a55233" | ||
PKG_SHA256="2775c6f9975d43aa6f6714de648fc1cab08b5c8de599cc942a9baad378c2cefe" | ||
PKG_ARCH="arm" | ||
PKG_LICENSE="BSD-3/custom" | ||
PKG_SITE="https://github.com/raspberrypi/rpi-eeprom" | ||
PKG_URL="https://github.com/raspberrypi/rpi-eeprom/archive/${PKG_VERSION}.tar.gz" | ||
PKG_DEPENDS_TARGET="flashrom" | ||
PKG_LONGDESC="rpi-eeprom: firmware, config and scripts to update RPi4 SPI bootloader" | ||
PKG_TOOLCHAIN="manual" | ||
|
||
makeinstall_target() { | ||
DESTDIR=${INSTALL}/$(get_kernel_overlay_dir)/lib/firmware/raspberrypi/bootloader | ||
|
||
mkdir -p ${DESTDIR} | ||
mkdir -p ${DESTDIR}/${_dir} | ||
cp -PRv ${PKG_BUILD}/firmware/recovery.bin ${DESTDIR} | ||
|
||
_dirs="critical" | ||
[ "$LIBREELEC_VERSION" = "devel" ] && _dirs+=" beta" | ||
for _dir in ${_dirs}; do | ||
if [ -n "$(ls -1 ${PKG_BUILD}/firmware/${_dir}/pieeprom-* 2>/dev/null)" ]; then | ||
mkdir -p ${DESTDIR}/${_dir} | ||
cp -PRv $(ls -1 ${PKG_BUILD}/firmware/${_dir}/pieeprom-* | tail -1) ${DESTDIR}/${_dir} | ||
fi | ||
done | ||
|
||
mkdir -p ${INSTALL}/usr/bin | ||
cp -PRv ${PKG_DIR}/source/rpi-eeprom-update ${INSTALL}/usr/bin | ||
cp -PRv ${PKG_BUILD}/rpi-eeprom-update ${INSTALL}/usr/bin/.rpi-eeprom-update.real | ||
cp -PRv ${PKG_BUILD}/rpi-eeprom-config ${INSTALL}/usr/bin | ||
|
||
mkdir -p ${INSTALL}/etc/default | ||
cp -PRv ${PKG_DIR}/config/* ${INSTALL}/etc/default | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
# If read-only then mount writeable, and restore read-only on exit | ||
# This means we don't restore read-only if /flash is already writeable | ||
if [ -n "$(grep " /flash " /proc/mounts | grep "[[:space:]]ro[[:space:],]")" ]; then | ||
trap "mount -o remount,ro /flash" EXIT | ||
mount -o remount,rw /flash | ||
fi | ||
|
||
sh /usr/bin/.rpi-eeprom-update.real $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters