summaryrefslogtreecommitdiffstats
path: root/meta-phosphor/common/recipes-phosphor/flash
diff options
context:
space:
mode:
authorMichael Tritz <mtritz@us.ibm.com>2017-07-13 16:26:15 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-07-24 18:58:57 +0000
commit9196bc389d1080e937381af78c3535e9c9f02ece (patch)
tree6fee0cf6702ae0dd2c438b42878f7a52e640718a /meta-phosphor/common/recipes-phosphor/flash
parent3fb3920d7587fc82f28a51a96fbbf7ff81f97415 (diff)
downloadtalos-openbmc-9196bc389d1080e937381af78c3535e9c9f02ece.tar.gz
talos-openbmc-9196bc389d1080e937381af78c3535e9c9f02ece.zip
BMC Code Mgmt: Service files for factory reset
This commit extends the obmc-flash-bmc script and includes a pair of service files. A U-Boot environment variable will be set to indicate that the BMC read-write volume needs to be reset. When this variable is present, the read-write volume will be removed and recreated. Change-Id: I6e39727cd3898d66bdbc63e9071f3a8b20a77673 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Diffstat (limited to 'meta-phosphor/common/recipes-phosphor/flash')
-rw-r--r--meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb1
-rw-r--r--meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc35
-rw-r--r--meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-setenv@.service7
3 files changed, 43 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb
index acdd9a3e2..f6f47b856 100644
--- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb
+++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb
@@ -63,6 +63,7 @@ DBUS_SERVICE_${PN}-updater += "xyz.openbmc_project.Software.BMC.Updater.service"
SYSTEMD_SERVICE_${PN}-updater += " \
obmc-flash-bmc-ubirw.service \
obmc-flash-bmc-ubiro@.service \
+ obmc-flash-bmc-setenv@.service \
"
# Name of the mtd device where the ubi volumes should be created
diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
index a45150327..5c960f3b8 100644
--- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
+++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -21,6 +21,11 @@ ubi_rw() {
rw="${rwmtd#mtd}"
ubidev="/dev/ubi${rw}"
+ if [ "$(fw_printenv rwreset)" == "rwreset=true" ]; then
+ ubi_remove
+ fw_setenv rwreset
+ fi
+
# Create a ubi volume of size 4MB, that is the current size of the rwfs image
vol="$(findubi "${name}")"
if [ -z "${vol}" ]; then
@@ -59,6 +64,28 @@ ubi_updatevol() {
ubiupdatevol "/dev/ubi${ubidevid}" "${img}"
}
+ubi_remove() {
+ vol="$(findubi "${name}")"
+
+ if [ ! -z "$vol" ]; then
+ vol="${vol%_*}"
+
+ if grep -q "${vol}:$name" /proc/mounts; then
+ mountdir=$(grep "${vol}:$name" /proc/mounts | cut -d " " -f 2)
+ umount "$mountdir"
+ rm -r "$mountdir"
+ fi
+
+ ubirmvol "/dev/${vol}" -N "$name"
+ fi
+}
+
+ubi_setenv() {
+ varName="${variable%"\x3d"*}"
+ value="${variable##*"\x3d"}"
+ fw_setenv "$varName" "$value"
+}
+
case "$1" in
ubirw)
reqmtd="$2"
@@ -84,6 +111,14 @@ case "$1" in
ubi_ro
ubi_updatevol
;;
+ ubiremove)
+ name="$2"
+ ubi_remove
+ ;;
+ ubisetenv)
+ variable="$2"
+ ubi_setenv
+ ;;
*)
echo "Invalid argument"
exit 1
diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-setenv@.service b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-setenv@.service
new file mode 100644
index 000000000..5c0650b9e
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-setenv@.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Set U-Boot environment variable
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart={sbindir}/obmc-flash-bmc ubisetenv %i
OpenPOWER on IntegriCloud