summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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