summaryrefslogtreecommitdiffstats
path: root/meta-openbmc-machines
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2017-05-25 15:48:27 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2017-06-01 09:20:10 -0500
commit69d3de017c3bcf4ade3fbd55aeb49b5b7074975d (patch)
tree48f0b50811e85c0ce5d512b70905e8f55061e49a /meta-openbmc-machines
parentf6442e13a4ffb9b295946630d2aac09c4e0a3a2e (diff)
downloadtalos-openbmc-69d3de017c3bcf4ade3fbd55aeb49b5b7074975d.tar.gz
talos-openbmc-69d3de017c3bcf4ade3fbd55aeb49b5b7074975d.zip
openpower-software-manager: Support migration to ubifs
A ubiattach is the first step for any ubi operations. If this service fails, it could be that the pnor chip is formatted differently, as with the case of flashing it with pflash. Enhance the service to: Check if the chip is formatted as a ubi device. If it's not, format it as ubi with a new ubiformat script. Reattempt the attach. This allows a pnor code update without the user having to manually reformat the chip. Closes openbmc/openbmc#1637 Change-Id: Id73b5eae40af68cd49e0ba0deb56efc36bd03981 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Diffstat (limited to 'meta-openbmc-machines')
-rw-r--r--meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb11
-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-bios-ubiattach.service2
4 files changed, 43 insertions, 1 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 bf8a12253..931a07d80 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
@@ -24,6 +24,17 @@ RDEPENDS_${PN} += " \
sdbusplus \
"
+S = "${WORKDIR}"
+SRC_URI += " \
+ file://bios-ubiattach \
+ file://bios-ubiformat"
+
+do_install() {
+ install -d ${D}${sbindir}
+ install -m 0755 ${WORKDIR}/bios-ubiattach ${D}${sbindir}/bios-ubiattach
+ install -m 0755 ${WORKDIR}/bios-ubiformat ${D}${sbindir}/bios-ubiformat
+}
+
DBUS_SERVICE_${PN} += "org.open_power.Software.Host.Updater.service"
SYSTEMD_SERVICE_${PN} += " \
obmc-flash-bios-ubiattach.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
new file mode 100644
index 000000000..accf7d824
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiattach
@@ -0,0 +1,23 @@
+#!/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
new file mode 100644
index 000000000..d62a6b23c
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/bios-ubiformat
@@ -0,0 +1,8 @@
+#!/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-ubiattach.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubiattach.service
index 90013ff1e..f90c43732 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,5 @@ Description=Attach the PNOR mtd device to UBI
[Service]
Type=oneshot
RemainAfterExit=yes
-ExecStart=/bin/sh -c 'grep pnor /proc/mtd |cut -c 4 |xargs {sbindir}/ubiattach /dev/ubi_ctrl -m'
+ExecStart={sbindir}/bios-ubiattach
ExecStop=/bin/sh -c 'grep pnor /proc/mtd |cut -c 4 |xargs {sbindir}/ubidetach /dev/ubi_ctrl -m'
OpenPOWER on IntegriCloud