summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2017-08-17 22:08:20 +0300
committerPatrick Williams <patrick@stwcx.xyz>2017-08-25 01:17:56 +0300
commitfbf143eabd096004e56311b6feb2c9b778e23340 (patch)
tree2fdcc6e403ebce018d925a4b64caddae62f598bb
parent0ad3b1df9079064491c8318bece22e63cc71b2f4 (diff)
downloadopenbmc-fbf143eabd096004e56311b6feb2c9b778e23340.tar.xz
obmc-flash-bmc: Add support for specifying alternate mtd devices
Add support to be able to specify an alternate mtd device to store a read-only image. The requested mtd devices should be separated by a plus sign. If an alternate mtd device is specified, store the image in the mtd where root is not currently mounted on to be able to alternate storage devices. Change-Id: Ic68584f431a5effe68da3c85b798c5818552108a Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc28
1 files changed, 26 insertions, 2 deletions
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 a75badd73..9af24ac8a 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
@@ -1,5 +1,18 @@
#!/bin/sh
+# Get the root mtd device number (mtdX) from "/dev/ubiblockX_Y on /"
+findrootmtd() {
+ rootmatch=" on / "
+ m="$(mount | grep "${rootmatch}" | grep "ubiblock")"
+ m="${m##*ubiblock}"
+ m="${m%_*}"
+ if [ -z "${m}" ]; then
+ # default to bmc mtd (0)
+ m=0
+ fi
+ echo "mtd${m}"
+}
+
# Get the mtd device number (mtdX)
findmtd() {
m="$(grep -xl "$1" /sys/class/mtd/*/name)"
@@ -35,6 +48,15 @@ ubi_rw() {
ubi_ro() {
romtd="$(findmtd "${reqmtd}")"
+ romtd2="$(findmtd "${reqmtd2}")"
+
+ if [ ! "${romtd}" == "${romtd2}" ]; then
+ # Request to use alternate mtd device, choose the non-root one
+ rootmtd="$(findrootmtd)"
+ if [ "${rootmtd}" == "${romtd}" ]; then
+ romtd="${romtd2}"
+ fi
+ fi
ro="${romtd#mtd}"
ubidev="/dev/ubi${ro}"
@@ -130,7 +152,8 @@ case "$1" in
ubi_rw
;;
ubiro)
- reqmtd="$2"
+ reqmtd="$(echo "$2" | cut -d "+" -f 1)"
+ reqmtd2="$(echo "$2" | cut -d "+" -f 2)"
name="$3"
version="$4"
imgfile="image-rofs"
@@ -140,7 +163,8 @@ case "$1" in
ubi_updatevol
;;
ubikernel)
- reqmtd="$2"
+ reqmtd="$(echo "$2" | cut -d "+" -f 1)"
+ reqmtd2="$(echo "$2" | cut -d "+" -f 2)"
name="$3"
version="$4"
imgfile="image-kernel"