summaryrefslogtreecommitdiff
path: root/meta-phosphor/recipes-phosphor/initrdscripts
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2023-02-09 21:45:46 +0300
committerPatrick Williams <patrick@stwcx.xyz>2023-02-10 06:26:13 +0300
commit4535b70af3616feb3b4bec04dff8c522b9dc3937 (patch)
tree2761c0c1aa8b8586ac3ee614b35324ededf70761 /meta-phosphor/recipes-phosphor/initrdscripts
parentd91b4b3bf903a59c9f7cd6edc8902afebcf29a5c (diff)
downloadopenbmc-4535b70af3616feb3b4bec04dff8c522b9dc3937.tar.xz
meta-phosphor: static-norootfs-init: support factory-reset
Add support to check the uboot environment for 'factory-reset' as programmed by phosphor-bmc-code-mgmt's FactoryReset interface. Tested: Ran the following and observed the file missing after reboot: ``` touch /var/DELETE_THIS_FILE busctl call xyz.openbmc_project.Software.BMC.Updater \ /xyz/openbmc_project/software \ xyz.openbmc_project.Common.FactoryReset Reset reboot ``` During the reboot observed the following message, along with ubiformat messages: ``` Formatting persistent volume: factory-reset ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I7c0d73cedc6414a590a0f99b68c843c88a7aded7
Diffstat (limited to 'meta-phosphor/recipes-phosphor/initrdscripts')
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb3
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/21-factory-reset13
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/30-ubiattach-or-format11
3 files changed, 26 insertions, 1 deletions
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb
index 61762a5c99..789431ba0f 100644
--- a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb
@@ -8,6 +8,7 @@ SOURCE_FILES = "\
init \
10-early-mounts \
20-udev \
+ 21-factory-reset \
30-ubiattach-or-format \
50-mount-persistent \
"
@@ -33,6 +34,8 @@ do_install() {
}
RDEPENDS:${PN} += " \
+ ${@d.getVar('PREFERRED_PROVIDER_u-boot-fw-utils', True) or \
+ 'u-boot-fw-utils'} \
${VIRTUAL-RUNTIME_base-utils} \
mtd-utils-ubifs \
udev \
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/21-factory-reset b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/21-factory-reset
new file mode 100644
index 0000000000..0c435f8924
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/21-factory-reset
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ ! -x /sbin/fw_printenv ]; then
+ exit 1
+fi
+
+# Need to create /run/lock so fw_printenv can create lockfile.
+mkdir /run/lock
+
+# Check uboot keys for 'factory-reset'
+if /sbin/fw_printenv openbmcinit openbmconce | grep -q factory-reset ; then
+ echo "factory-reset" >> /run/format-persist
+fi
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/30-ubiattach-or-format b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/30-ubiattach-or-format
index 8a0cbc6ccf..39aa8769eb 100644
--- a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/30-ubiattach-or-format
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/30-ubiattach-or-format
@@ -4,7 +4,16 @@ if [ ! -e /dev/mtd/rwfs ]; then
exit 1
fi
-if ! ubiattach -p /dev/mtd/rwfs > /dev/null ; then
+if [ ! -e /run/format-persist ]; then
+ if ! ubiattach -p /dev/mtd/rwfs > /dev/null ; then
+ echo "unformatted-ubi" >> /run/format-persist
+ fi
+fi
+
+if [ -e /run/format-persist ]; then
+ echo "Formatting persistent volume: "
+ cat /run/format-persist
+
if ! ubiformat --yes /dev/mtd/rwfs ; then
exit 1
fi