swupdate: add script to provide runtime hardware revision
authorHugo Villeneuve <hugo@hugovil.com>
Tue, 9 Sep 2025 18:48:32 +0000 (14:48 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Tue, 9 Sep 2025 19:22:32 +0000 (15:22 -0400)
Signed-off-by: Hugo Villeneuve <hugo@hugovil.com>
recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in [new file with mode: 0644]
recipes-support/swupdate/swupdate_%.bbappend [new file with mode: 0644]

diff --git a/recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in b/recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in
new file mode 100644 (file)
index 0000000..44bdf5d
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# TODO: the revision should be read at bootup from an EEPROM or other means.
+# For now, it is simply hardcoded.
+HWREV="revA"
+
+DESTDIR="/var/run/swupdate"
+DESTFILE="${DESTDIR}/hwrevision"
+
+mkdir -p ${DESTDIR}
+
+echo "@MACHINE@ ${HWREV}" > ${DESTFILE}
diff --git a/recipes-support/swupdate/swupdate_%.bbappend b/recipes-support/swupdate/swupdate_%.bbappend
new file mode 100644 (file)
index 0000000..a475262
--- /dev/null
@@ -0,0 +1,12 @@
+FILESEXTRAPATHS:prepend:hvmpd := "${THISDIR}/${PN}:"
+
+SRC_URI:append:hvmpd = " \
+    file://97-hwrevision-hardcoded.sh.in \
+"
+
+do_install:append:hvmpd() {
+    sed -e s/@MACHINE@/${MACHINE}/ \
+        ${WORKDIR}/97-hwrevision-hardcoded.sh.in > ${WORKDIR}/97-hwrevision-hardcoded.sh
+    install -d ${D}${libdir}/swupdate/conf.d/
+    install -m 644 ${WORKDIR}/97-hwrevision-hardcoded.sh ${D}${libdir}/swupdate/conf.d/
+}