phosphor-software-manager: New service file to create ubi rw volume
Add service file and script to create a ubi read-write volume
to store the rwfs. The volume would be 4MB as that's the current
size of the rwfs image.
The volume is not tied to a version so that read-write data is
persisted through bmc code updates.
The mtd device location can be passed through the recipe.
Set it to the "pnor" mtd as the default. This can be changed via a
per-system bbappend to other chips if desired, such as the alternate
bmc chip.
Change-Id: Id3e40e28eaf60c9fdccdca1484d144014f2bc8df
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
new file mode 100644
index 0000000..16c5f32
--- /dev/null
+++ b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Get the mtd device number (mtdX)
+findmtd() {
+ m="$(grep -xl "$1" /sys/class/mtd/*/name)"
+ m="${m%/name}"
+ m="${m##*/}"
+ echo "${m}"
+}
+
+# Get the ubi device number (ubiX_Y)
+findubi() {
+ u="$(grep -xl "$1" /sys/class/ubi/ubi?/subsystem/ubi*/name)"
+ u="${u%/name}"
+ u="${u##*/}"
+ echo "${u}"
+}
+
+ubi_rw() {
+ rwmtd="$(findmtd "${reqmtd}")"
+ rw="${rwmtd#mtd}"
+ ubidev="/dev/ubi${rw}"
+
+ # Create a ubi volume of size 4MB, that is the current size of the rwfs image
+ vol="$(findubi "${name}")"
+ if [ -z "${vol}" ]; then
+ ubimkvol "${ubidev}" -N "${name}" -s 4MiB
+ fi
+}
+
+case "$1" in
+ ubirw)
+ reqmtd="$2"
+ name="$3"
+ ubi_rw
+ ;;
+ *)
+ echo "Invalid argument"
+ exit 1
+ ;;
+esac
+rc=$?
+if [ ${rc} -ne 0 ]; then
+ echo "$0: error ${rc}"
+ exit ${rc}
+fi
diff --git a/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubirw.service b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubirw.service
new file mode 100644
index 0000000..cef57e0
--- /dev/null
+++ b/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubirw.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Create BMC read-write ubi volume
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart={sbindir}/obmc-flash-bmc ubirw {RW_MTD} rw