From eb8644742b22a77f40e6cfe9f3d325e92a602def Mon Sep 17 00:00:00 2001 From: "Edward A. James" Date: Mon, 21 Aug 2017 16:08:44 -0500 Subject: Do not allow power on if PNOR doesn't have required image - The new BMC code requires the UBI based PNOR image to be loaded before HOST turns on. If the PNOR is not formatted as UBI, we want a clear error in the journal and quick fail to boot to notify the user. Resolves openbmc/openbmc#2117 Change-Id: I547ba488a94c5b5871c6327b0fd3af678c656b1b Signed-off-by: Saqib Khan Signed-off-by: Edward A. James --- .../recipes-phosphor/mboxd/mboxd.bbappend | 11 +++++++++++ .../mboxd/mboxd/check-pnor-format.service | 11 +++++++++++ .../recipes-phosphor/mboxd/mboxd/check_pnor_format.sh | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check-pnor-format.service create mode 100644 meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check_pnor_format.sh (limited to 'meta-openbmc-machines/meta-openpower') diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd.bbappend index 8b6248a46..ac35ae9b4 100644 --- a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd.bbappend +++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd.bbappend @@ -1 +1,12 @@ MBOXD_FLASH_SIZE = "64M" + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SYSTEMD_SERVICE_${PN} += "check-pnor-format.service" + +SRC_URI += "file://check_pnor_format.sh" + +do_install_append() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/check_pnor_format.sh ${D}${bindir}/check_pnor_format.sh +} diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check-pnor-format.service b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check-pnor-format.service new file mode 100644 index 000000000..88bf0ad39 --- /dev/null +++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check-pnor-format.service @@ -0,0 +1,11 @@ +[Unit] +Description=Check PNOR UBI format +Before=mboxd.service + +[Service] +ExecStart={bindir}/check_pnor_format.sh +Type=oneshot +RemainAfterExit=yes + +[Install] +RequiredBy=mboxd.service diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check_pnor_format.sh b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check_pnor_format.sh new file mode 100644 index 000000000..ec043eaf9 --- /dev/null +++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/mboxd/mboxd/check_pnor_format.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Get the mtd device number (mtdX) +findmtd() { + m="$(grep -xl "$1" /sys/class/mtd/*/name)" + m="${m%/name}" + m="${m##*/}" + echo "${m}" +} + +pnormtd="$(findmtd pnor)" +pnor="${pnormtd#mtd}" +pnordev="/dev/mtd${pnor}" + +if [[ ! "$(dd if=${pnordev} bs=1 count=3 2> /dev/null)" = "UBI" ]]; then + echo "${pnordev} is not formatted UBI" + exit 1 +fi -- cgit v1.2.1