From: Hugo Villeneuve Date: Sat, 13 Dec 2025 16:38:47 +0000 (-0500) Subject: Simplify hwrev configuration X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=5678087c4c0954d0ec06acb09726929d5018bbbb;p=yocto%2Fmeta-hvmpd.git Simplify hwrev configuration Uses new hwrev class in meta-dimonoff to simplify hwrev configuration for swupdate and scripts. The following variables are now automatically set by hwrev class: HWREV_LATEST HWREV_LATEST_NUM HWREV_PREFIX ?= "rev" Signed-off-by: Hugo Villeneuve --- diff --git a/raspberrypi/conf/machine/raspberrypi-extra.conf b/raspberrypi/conf/machine/raspberrypi-extra.conf index 26f7c68..1c544b0 100644 --- a/raspberrypi/conf/machine/raspberrypi-extra.conf +++ b/raspberrypi/conf/machine/raspberrypi-extra.conf @@ -20,10 +20,8 @@ VIDEO_CAMERA = "0" WKS_FILE = "hvmpd-raspberrypi.wks.in" -# List of hardware versions supported by our swupdate setup. Each revision must -# be enclosed within double-quotes, and separated with a comma. -# Exemple: SWUPDATE_HWREV = ""revA", "revB"" -SWUPDATE_HWREV = ""revA"" +# List of hardware versions supported by our swupdate setup. +HWREV_LIST = "A" RPI_KERNEL_DEVICETREE_OVERLAYS += " \ overlays/hvmpd.dtbo \ diff --git a/recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in b/recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in index 44bdf5d..8672113 100644 --- a/recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in +++ b/recipes-support/swupdate/swupdate/97-hwrevision-hardcoded.sh.in @@ -1,12 +1,26 @@ #!/bin/sh -# TODO: the revision should be read at bootup from an EEPROM or other means. -# For now, it is simply hardcoded. -HWREV="revA" +. /usr/bin/dimonoff.sh +# Note: this script is sourced by swupdate. In case of success, we must not use +# the exit statement, but return. Exit is ok in case of error. + +# Write infos under /var/run so that it works for read-only rootfs DESTDIR="/var/run/swupdate" DESTFILE="${DESTDIR}/hwrevision" +EEPROM_I2C_DEVNUM="@EEPROM_I2C_DEVNUM@" + +devpath="/sys/bus/i2c/devices/${EEPROM_I2C_DEVNUM}/eeprom" + +# Define default hardware revision. +# If the EEPROM is present, when we exit, the next script executed by +# swupdate (98-hwrevision-tlv-eeprom.sh) will handle the actual hardware +# revision stored in the TLV EEPROM. + mkdir -p ${DESTDIR} +echo "@MACHINE@ @HWREV_LATEST@" > ${DESTFILE} -echo "@MACHINE@ ${HWREV}" > ${DESTFILE} +if [ ! -f ${devpath} ]; then + log_warn "EEPROM not found, using hardcoded hardware revision (@HWREV_LATEST@)" +fi diff --git a/recipes-support/swupdate/swupdate_%.bbappend b/recipes-support/swupdate/swupdate_%.bbappend index a475262..350bd51 100644 --- a/recipes-support/swupdate/swupdate_%.bbappend +++ b/recipes-support/swupdate/swupdate_%.bbappend @@ -4,9 +4,16 @@ SRC_URI:append:hvmpd = " \ file://97-hwrevision-hardcoded.sh.in \ " +inherit hwrev + do_install:append:hvmpd() { - sed -e s/@MACHINE@/${MACHINE}/ \ - ${WORKDIR}/97-hwrevision-hardcoded.sh.in > ${WORKDIR}/97-hwrevision-hardcoded.sh + cp ${WORKDIR}/97-hwrevision-hardcoded.sh.in ${WORKDIR}/97-hwrevision-hardcoded.sh + + sed -e "s!@MACHINE@!${MACHINE}!g" \ + -e "s!@EEPROM_I2C_DEVNUM@!${EEPROM_I2C_DEVNUM}!g" \ + -e "s!@HWREV_LATEST@!${HWREV_LATEST}!g" \ + -i ${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/ } diff --git a/wandboard/conf/machine/wandboard-extra.conf b/wandboard/conf/machine/wandboard-extra.conf index 95c8fb5..290d664 100644 --- a/wandboard/conf/machine/wandboard-extra.conf +++ b/wandboard/conf/machine/wandboard-extra.conf @@ -15,7 +15,5 @@ IMAGE_FSTYPES = "tar.xz wic.gz wic.bmap" WKS_FILE = "hvmpd-wandboard.wks.in" -# List of hardware versions supported by our swupdate setup. Each revision must -# be enclosed within double-quotes, and separated with a comma. -# Exemple: SWUPDATE_HWREV = ""revA", "revB"" -SWUPDATE_HWREV = ""revA"" +# List of hardware versions supported by our swupdate setup. +HWREV_LIST = "A"