Skip to content

Commit 48d393e

Browse files
authored
Show if flashrom needs to be used by rpi-eeprom-update in tool output (#4718)
Previously we needed to call rpi-eeprom-update -b to learn if flashrom must be used (which returned an error in that case) and there was no info if flashrom update is available. Extend the output of the default printVersions output to show this information as well, as it's rather inexpensive to check it and it makes it easier to offer relevant update entities based on that. Part of #4631
1 parent 820768d commit 48d393e

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <sairon@sairon.cz>
3+
Date: Mon, 18 May 2026 15:47:24 +0200
4+
Subject: [PATCH] rpi-eeprom-update: add early checks for flashrom availability
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
Add check if flashrom needs to be used before it's actually attempted
10+
and print the result in the version output, along with flashrom
11+
availability. This makes it easier to check version and offer available
12+
updates as Home Assistant update entities.
13+
14+
Signed-off-by: Jan Čermák <sairon@sairon.cz>
15+
Upstream: not applicable
16+
---
17+
rpi-eeprom-update | 57 +++++++++++++++++++++++++++++++++++++++--------
18+
1 file changed, 48 insertions(+), 9 deletions(-)
19+
20+
diff --git a/rpi-eeprom-update b/rpi-eeprom-update
21+
index 354344c..82832a8 100755
22+
--- a/rpi-eeprom-update
23+
+++ b/rpi-eeprom-update
24+
@@ -78,6 +78,10 @@ ACTION_UPDATE_BOOTLOADER=0
25+
ACTION_UPDATE_VL805=0
26+
CHECKSUMS=''
27+
28+
+# Set by checkUpdateMethod: 1 when the current boot device cannot apply an
29+
+# EEPROM update (not booting from SD card and flashrom is not usable).
30+
+UPDATE_BLOCKED=0
31+
+
32+
cleanup() {
33+
if [ -f "${CHECKSUMS}" ]; then
34+
rm -f "${CHECKSUMS}"
35+
@@ -440,12 +444,9 @@ checkDependencies() {
36+
37+
# Default to off - in the future Raspberry Pi 5 may default to using flashrom if
38+
# flashrom is available.
39+
- if [ "${AUTO_UPDATE_BOOTLOADER}" = 1 ] || [ -n "${BOOTLOADER_UPDATE_IMAGE}" ]; then
40+
- [ -z "${RPI_EEPROM_USE_FLASHROM}" ] && RPI_EEPROM_USE_FLASHROM=0
41+
- if [ "${RPI_EEPROM_USE_FLASHROM}" -eq 1 ] && ! command -v flashrom > /dev/null; then
42+
- warn "WARNING: flashrom not found. Setting RPI_EEPROM_USE_FLASHROM to 0"
43+
- RPI_EEPROM_USE_FLASHROM=0
44+
- fi
45+
+ [ -z "${RPI_EEPROM_USE_FLASHROM}" ] && RPI_EEPROM_USE_FLASHROM=0
46+
+ if [ "${RPI_EEPROM_USE_FLASHROM}" -eq 1 ] && ! command -v flashrom > /dev/null; then
47+
+ die "flashrom not found but RPI_EEPROM_USE_FLASHROM is set to 1."
48+
fi
49+
50+
FIRMWARE_IMAGE_DIR="${FIRMWARE_ROOT}-${BCM_CHIP}/${FIRMWARE_RELEASE_STATUS}"
51+
@@ -720,6 +721,41 @@ printVersions()
52+
echo " CURRENT: ${VL805_CURRENT_VERSION}"
53+
echo " LATEST: ${VL805_UPDATE_VERSION}"
54+
fi
55+
+
56+
+ echo ""
57+
+ if [ "${RPI_EEPROM_USE_FLASHROM}" = 1 ]; then
58+
+ echo " FLASHROM: yes"
59+
+ else
60+
+ echo " FLASHROM: no"
61+
+ fi
62+
+
63+
+ checkUpdateMethod
64+
+ if [ "${UPDATE_BLOCKED}" = 1 ]; then
65+
+ echo " BLOCKED: yes"
66+
+ else
67+
+ echo " BLOCKED: no"
68+
+ fi
69+
+}
70+
+
71+
+# checkUpdateMethod is the non-fatal counterpart of findBootFS: it checks
72+
+# whether a pending EEPROM update could actually be applied on this device,
73+
+# without mounting anything or aborting, and records the result in
74+
+# UPDATE_BLOCKED. This lets the version-check output report the boot-device
75+
+# status inline instead of only failing once an update is attempted.
76+
+checkUpdateMethod()
77+
+{
78+
+ if blkid | grep -qE "/dev/mmcblk0p1.*LABEL_FATBOOT.*hassos-boot.*TYPE.*vfat"; then
79+
+ # Booting from the SD card - recovery.bin can be staged on /mnt/boot.
80+
+ UPDATE_BLOCKED=0
81+
+ elif [ -n "${BOOTFS}" ]; then
82+
+ # BOOTFS explicitly provided via /etc/default/rpi-eeprom-update
83+
+ UPDATE_BLOCKED=0
84+
+ elif [ "${RPI_EEPROM_USE_FLASHROM}" = "1" ]; then
85+
+ # flashrom writes the SPI EEPROM directly, no boot partition required
86+
+ UPDATE_BLOCKED=0
87+
+ else
88+
+ UPDATE_BLOCKED=1
89+
+ fi
90+
}
91+
92+
findBootFS()
93+
@@ -729,14 +765,17 @@ findBootFS()
94+
# If ${BOOTFS} is not writable OR is not on /dev/mmcblk0 then error because the ROM
95+
# can only load recovery.bin from the on-board SD-CARD slot or the EEPROM.
96+
97+
+ checkUpdateMethod
98+
+ if [ "${UPDATE_BLOCKED}" = 1 ]; then
99+
+ die "rpi-eeprom-update is only available when booting from an SD card or if flashrom can be used."
100+
+ fi
101+
+
102+
if blkid | grep -qE "/dev/mmcblk0p1.*LABEL_FATBOOT.*hassos-boot.*TYPE.*vfat"; then
103+
# use HAOS default bootfs location if booting from SD card
104+
BOOTFS="/mnt/boot"
105+
- elif [ -z "$BOOTFS" ] && [ "${RPI_EEPROM_USE_FLASHROM}" = "1" ]; then
106+
+ elif [ -z "$BOOTFS" ]; then
107+
# image for flashrom will created in bootfs
108+
BOOTFS="/mnt/boot"
109+
- elif [ -z "$BOOTFS" ]; then
110+
- die "rpi-eeprom-update is only available when booting from an SD card or if flashrom can be used."
111+
fi
112+
113+
# If BOOTFS is not a directory or doesn't contain any .elf files then

0 commit comments

Comments
 (0)