summaryrefslogtreecommitdiffstats
path: root/meta-openbmc-machines/meta-openpower
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2017-07-06 10:31:59 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2017-07-19 12:35:04 -0500
commite253838a23d1d356986b8f726f48729305617c4f (patch)
treec20976d36ec5e1a243852ac9a37f085ef9995ac7 /meta-openbmc-machines/meta-openpower
parenta450b86aff71ed830f9ea2aa1edca41bf05e00bf (diff)
downloadtalos-openbmc-e253838a23d1d356986b8f726f48729305617c4f.tar.gz
talos-openbmc-e253838a23d1d356986b8f726f48729305617c4f.zip
openpower-software-manager: Move ubiattach and ubiformat to single script
The service files that manage the pnor ubi volumes and mount points are starting to get too much logic in them. Create a single shell script instead of having all the commands and logic in the service files. Also specify the ubi device number in ubiattach via the -d parameter so that it matches the pnor mtd device number. In that way we always know what the ubi device for pnor is, for when the bmc chip is formatted with ubi we can differentiate them. Remove the ExecStop entry on the service file, no need to detach the volume when any service file stops. Change-Id: Ib41592ea40ef8e58602100bb3ab51c5f4faada18 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'meta-openbmc-machines/meta-openpower')
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb7
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiattach23
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiformat8
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios49
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiattach.service3
5 files changed, 52 insertions, 38 deletions
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb
index fa4a20fa5..28949a8b0 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb
@@ -28,16 +28,13 @@ S = "${WORKDIR}/git"
SRC_URI += "git://github.com/openbmc/openpower-pnor-code-mgmt"
-SRC_URI += " \
- file://bios-ubiattach \
- file://bios-ubiformat"
+SRC_URI += "file://obmc-flash-bios"
SRCREV = "a8eda56300d309cb11566787d70fd1b9a5721e07"
do_install_append() {
install -d ${D}${sbindir}
- install -m 0755 ${WORKDIR}/bios-ubiattach ${D}${sbindir}/bios-ubiattach
- install -m 0755 ${WORKDIR}/bios-ubiformat ${D}${sbindir}/bios-ubiformat
+ install -m 0755 ${WORKDIR}/obmc-flash-bios ${D}${sbindir}/obmc-flash-bios
}
DBUS_SERVICE_${PN} += "org.open_power.Software.Host.Updater.service"
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiattach b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiattach
deleted file mode 100644
index accf7d824..000000000
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiattach
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-# Get the pnor mtd device number
-pnor=`grep pnor /proc/mtd |cut -c 4`
-
-# Attach the pnor mtd device to ubi
-ubiattach /dev/ubi_ctrl -m $pnor
-if [ $? -ne 0 ]
-then
- # Check the pnor mtd device is formatted as ubi by reading the first 3 byes,
- # which should be the ascii chars 'UBI'
- magic=`hexdump -C -n 3 /dev/mtd$pnor`
- if [[ $magic == *"UBI"* ]]
- then
- # Device already formatted as ubi, ubiattach failed for some other reason
- exit -1
- else
- # Format device as ubi
- bios-ubiformat
- # Retry the ubiattach
- ubiattach /dev/ubi_ctrl -m $pnor
- fi
-fi
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiformat b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiformat
deleted file mode 100644
index d62a6b23c..000000000
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiformat
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-# Get the mtd device number for pnor
-pnor=`grep pnor /proc/mtd |cut -c 4`
-
-# Format the pnor mtd device as ubi
-echo "Starting ubiformat /dev/mtd$pnor"
-ubiformat /dev/mtd$pnor -y -q
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
new file mode 100644
index 000000000..acc550ba4
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# Get the mtd device number (mtdX)
+findmtd() {
+ m="$(grep -xl "$1" /sys/class/mtd/*/name)"
+ m="${m%/name}"
+ m="${m##*/}"
+ echo "${m}"
+}
+
+# Attach the pnor mtd device to ubi
+attach_ubi() {
+ pnormtd="$(findmtd pnor)"
+ pnor="${pnormtd#mtd}"
+ pnordev="/dev/mtd${pnor}"
+
+ ubiattach /dev/ubi_ctrl -m "${pnor}" -d "${pnor}"
+ rc=$?
+ if [ ${rc} -ne 0 ]; then
+ # Check the pnor mtd device is formatted as ubi by reading the first 3 byes,
+ # which should be the ascii chars 'UBI'
+ magic="$(hexdump -C -n 3 ${pnordev})"
+ if [[ "${magic}" =~ "UBI" ]]; then
+ # Device already formatted as ubi, ubiattach failed for some other reason
+ return ${rc}
+ else
+ # Format device as ubi
+ echo "Starting ubiformat ${pnordev}"
+ ubiformat "${pnordev}" -y -q
+ # Retry the ubiattach
+ ubiattach /dev/ubi_ctrl -m "${pnor}" -d "${pnor}"
+ fi
+ fi
+}
+
+case "$1" in
+ ubiattach)
+ attach_ubi
+ ;;
+ *)
+ echo "Invalid argument"
+ exit 1
+ ;;
+esac
+rc=$?
+if [ ${rc} -ne 0 ]; then
+ echo "$0: error ${rc}"
+ exit ${rc}
+fi
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiattach.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiattach.service
index f90c43732..bae633de2 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiattach.service
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiattach.service
@@ -4,5 +4,4 @@ Description=Attach the PNOR mtd device to UBI
[Service]
Type=oneshot
RemainAfterExit=yes
-ExecStart={sbindir}/bios-ubiattach
-ExecStop=/bin/sh -c 'grep pnor /proc/mtd |cut -c 4 |xargs {sbindir}/ubidetach /dev/ubi_ctrl -m'
+ExecStart={sbindir}/obmc-flash-bios ubiattach
OpenPOWER on IntegriCloud