PNOR: Check if device formatted as UBI.
- Check if device is formatted as "UBI" before
attempting to re-attach the pnor mtd device
to ubi.
- This helps reduce the error logs that we get
on systems that doesn't support UBI, such as
barreleye.
Resolves openbmc/openbmc#2066
Change-Id: I21091644950aa245df655d0a871e0f203782932c
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
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
index 0cdf74e..07931b6 100644
--- 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
@@ -144,16 +144,11 @@
pnordev="/dev/mtd${pnor}"
# Re-Attach the pnor mtd device to ubi
- 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 not formatted as ubi.
- return
- fi
+ if [[ $(hexdump -C -n 3 ${pnordev}) =~ "UBI" ]]; then
+ ubiattach /dev/ubi_ctrl -m "${pnor}" -d "${pnor}"
+ else
+ # Device not formatted as ubi.
+ return 0
fi
# Get information on all ubi volumes