vpnor: Move clearvolatile services to vpnor
The clearvolatile services were originally in the ubi layout, but
the functionality is purely for vpnor, not tied to a filesystem
layout. Move them to the vpnor layer where non-UBI layouts that use
virtual pnor such as eMMC have this functionality.
Tested: Verified on witherspoon that the renamed services were
included in the image and ran during a power on.
Change-Id: I6e9e9e4f5a8a7690a46872ee2fdc0fc96e621482
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/ubi/Makefile.am.include b/ubi/Makefile.am.include
index 2e5b6e5..3e442f8 100644
--- a/ubi/Makefile.am.include
+++ b/ubi/Makefile.am.include
@@ -9,9 +9,7 @@
if HAVE_SYSTEMD
systemdsystemunit_DATA += \
- %reldir%/obmc-flash-bios-check-clearvolatile@.service \
%reldir%/obmc-flash-bios-cleanup.service \
- %reldir%/obmc-flash-bios-enable-clearvolatile@.service \
%reldir%/obmc-flash-bios-ubiattach.service \
%reldir%/obmc-flash-bios-ubimount@.service \
%reldir%/obmc-flash-bios-ubipatch.service \
diff --git a/ubi/obmc-flash-bios b/ubi/obmc-flash-bios
index b15ddc6..7ea9afe 100644
--- a/ubi/obmc-flash-bios
+++ b/ubi/obmc-flash-bios
@@ -228,40 +228,6 @@
done
}
-clear_volatile() {
- service=$(mapper get-service /org/open_power/control/volatile)
- clearVolatileEnabled=$(busctl get-property $service /org/open_power/control/volatile xyz.openbmc_project.Object.Enable Enabled)
- if [[ "$clearVolatileEnabled" != "b true" ]]; then
- return 0
- fi
-
- PNOR_TOC_FILE="pnor.toc"
- PNOR_RO_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/ro/"
- PNOR_RW_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/rw/"
- PNOR_PRSV_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/prsv/"
-
- # toc partition string format:
- # partition27=HB_VOLATILE,0x02ba9000,0x02bae000,00,ECC,VOLATILE,READWRITE
- tocFilePath="${PNOR_RO_ACTIVE_PATH}${PNOR_TOC_FILE}"
- volatiles=($(grep VOLATILE "${tocFilePath}" | grep -Eo '^partition([0-9]+)=([A-Za-z0-9_]+)'))
- for (( index=0; index<${#volatiles[@]}; index++ )); do
- volatileName="$(echo ${volatiles[${index}]} | awk -F '=' '{print $2}')"
-
- rwVolatile="${PNOR_RW_ACTIVE_PATH}${volatileName}"
- if [ -f "${rwVolatile}" ]; then
- echo "Clear $rwVolatile"
- rm "${rwVolatile}"
- fi
- prsvVolatile="${PNOR_PRSV_ACTIVE_PATH}${volatileName}"
- if [ -f "${prsvVolatile}" ]; then
- echo "Clear $prsvVolatile"
- rm "${prsvVolatile}"
- fi
- done
- # Always reset the sensor after clearing
- busctl set-property $service /org/open_power/control/volatile xyz.openbmc_project.Object.Enable Enabled b false
-}
-
case "$1" in
ubiattach)
attach_ubi
@@ -285,9 +251,6 @@
ubicleanup)
ubi_cleanup
;;
- clearvolatile)
- clear_volatile
- ;;
*)
echo "Invalid argument"
exit 1
diff --git a/vpnor/Makefile.am.include b/vpnor/Makefile.am.include
index 49d9c1a..ce7e535 100644
--- a/vpnor/Makefile.am.include
+++ b/vpnor/Makefile.am.include
@@ -3,5 +3,7 @@
if HAVE_SYSTEMD
systemdsystemunit_DATA += \
+ %reldir%/obmc-vpnor-check-clearvolatile@.service \
+ %reldir%/obmc-vpnor-enable-clearvolatile@.service \
%reldir%/obmc-vpnor-updatesymlinks.service
endif
diff --git a/ubi/obmc-flash-bios-check-clearvolatile@.service b/vpnor/obmc-vpnor-check-clearvolatile@.service
similarity index 70%
rename from ubi/obmc-flash-bios-check-clearvolatile@.service
rename to vpnor/obmc-vpnor-check-clearvolatile@.service
index a5c69ea..c303721 100644
--- a/ubi/obmc-flash-bios-check-clearvolatile@.service
+++ b/vpnor/obmc-vpnor-check-clearvolatile@.service
@@ -1,13 +1,13 @@
[Unit]
Description=Clear the Volatile PNOR partitions in host%I if Enabled
-After=obmc-flash-bios-enable-clearvolatile@%i.service
+After=obmc-vpnor-enable-clearvolatile@%i.service
Before=obmc-host-start-pre@%i.target
ConditionPathExists=!/run/openbmc/host@%i-on
[Service]
Type=oneshot
RemainAfterExit=no
-ExecStart=/usr/bin/obmc-flash-bios clearvolatile
+ExecStart=/usr/bin/obmc-vpnor-util clearvolatile
[Install]
RequiredBy=obmc-host-startmin@%i.target
diff --git a/ubi/obmc-flash-bios-enable-clearvolatile@.service b/vpnor/obmc-vpnor-enable-clearvolatile@.service
similarity index 83%
rename from ubi/obmc-flash-bios-enable-clearvolatile@.service
rename to vpnor/obmc-vpnor-enable-clearvolatile@.service
index bdadc30..bad59b1 100644
--- a/ubi/obmc-flash-bios-enable-clearvolatile@.service
+++ b/vpnor/obmc-vpnor-enable-clearvolatile@.service
@@ -3,14 +3,14 @@
After=obmc-host-reset-running@%i.target
Wants=mapper-wait@-org-open_power-control-volatile.service
After=mapper-wait@-org-open_power-control-volatile.service
-Before=obmc-flash-bios-check-clearvolatile@%i.service
+Before=obmc-vpnor-check-clearvolatile@%i.service
ConditionPathExists=!/run/openbmc/host@%i-on
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/bin/sh -c "busctl set-property `mapper get-service /org/open_power/control/volatile` /org/open_power/control/volatile xyz.openbmc_project.Object.Enable Enabled b true"
-SyslogIdentifier=obmc-flash-bios-enable-clearvolatile
+SyslogIdentifier=obmc-vpnor-enable-clearvolatile
[Install]
RequiredBy=obmc-host-start@%i.target
diff --git a/vpnor/obmc-vpnor-util b/vpnor/obmc-vpnor-util
index 25e6726..2abf8fb 100644
--- a/vpnor/obmc-vpnor-util
+++ b/vpnor/obmc-vpnor-util
@@ -1,5 +1,39 @@
#!/bin/sh
+clear_volatile() {
+ service=$(mapper get-service /org/open_power/control/volatile)
+ clearVolatileEnabled=$(busctl get-property $service /org/open_power/control/volatile xyz.openbmc_project.Object.Enable Enabled)
+ if [[ "$clearVolatileEnabled" != "b true" ]]; then
+ return 0
+ fi
+
+ PNOR_TOC_FILE="pnor.toc"
+ PNOR_RO_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/ro/"
+ PNOR_RW_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/rw/"
+ PNOR_PRSV_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/prsv/"
+
+ # toc partition string format:
+ # partition27=HB_VOLATILE,0x02ba9000,0x02bae000,00,ECC,VOLATILE,READWRITE
+ tocFilePath="${PNOR_RO_ACTIVE_PATH}${PNOR_TOC_FILE}"
+ volatiles=($(grep VOLATILE "${tocFilePath}" | grep -Eo '^partition([0-9]+)=([A-Za-z0-9_]+)'))
+ for (( index=0; index<${#volatiles[@]}; index++ )); do
+ volatileName="$(echo ${volatiles[${index}]} | awk -F '=' '{print $2}')"
+
+ rwVolatile="${PNOR_RW_ACTIVE_PATH}${volatileName}"
+ if [ -f "${rwVolatile}" ]; then
+ echo "Clear $rwVolatile"
+ rm "${rwVolatile}"
+ fi
+ prsvVolatile="${PNOR_PRSV_ACTIVE_PATH}${volatileName}"
+ if [ -f "${prsvVolatile}" ]; then
+ echo "Clear $prsvVolatile"
+ rm "${prsvVolatile}"
+ fi
+ done
+ # Always reset the sensor after clearing
+ busctl set-property $service /org/open_power/control/volatile xyz.openbmc_project.Object.Enable Enabled b false
+}
+
update_symlinks() {
PNOR_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/"
PNOR_RO_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/ro"
@@ -60,6 +94,9 @@
}
case "$1" in
+ clearvolatile)
+ clear_volatile
+ ;;
updatesymlinks)
update_symlinks
;;