[PATCH openbmc 4/9] openbmc: Generate images with empty NOR sections in the erased state

OpenBMC Patches openbmc-patches at stwcx.xyz
Thu Feb 25 05:40:19 AEDT 2016


From: Andrew Jeffery <andrew at aj.id.au>

An erased NOR partition is considered to be a valid JFFS2 filesystem
(i.e. can be successfully mounted as JFFS2). As such there's no need to
execute mkfs to produce an empty JFFS2 image if the target partition is
in the erased state. Thus, when generating the flash-palmetto and
image-rwfs image files, start with a base image file in the erased state
(with all bits set).

The change shifts the common logic to generate the base image files into
a shell function.

Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
---
 meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
index bf987bb..96193a3 100644
--- a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
@@ -27,6 +27,13 @@ RWFS_SIZE ?= "4096"
 
 # IMAGE_POSTPROCESS_COMMAND += "do_generate_flash"
 
+mk_nor_image() {
+       image_dst="$1"
+       image_size_kb=$2
+       dd if=/dev/zero bs=1k count=${image_size_kb} \
+              | tr '\000' '\377' > ${image_dst}
+}
+
 do_generate_flash() {
        INITRD_CTYPE=${INITRAMFS_CTYPE}
        ddir="${DEPLOY_DIR_IMAGE}"
@@ -51,12 +58,12 @@ do_generate_flash() {
        fi
 
        oe_mkimage  "${initrd}" "${INITRD_CTYPE}" || bbfatal "oe_mkimage initrd"
-       dd if=/dev/zero of=${ddir}/${rwfs} bs=1k count=${RWFS_SIZE}
+       mk_nor_image ${ddir}/${rwfs} ${RWFS_SIZE}
        mkfs.${OVERLAY_BASETYPE} -b 4096 -F -O^huge_file ${ddir}/${rwfs} || bbfatal "mkfs rwfs"
 
        dst="${ddir}/${FLASH_IMAGE_NAME}"
        rm -rf $dst
-       dd if=/dev/zero of=${dst} bs=1k count=${FLASH_SIZE}
+       mk_nor_image ${dst} ${FLASH_SIZE}
        dd if=${ddir}/${uboot} of=${dst} bs=1k seek=${FLASH_UBOOT_OFFSET}
        dd if=${ddir}/${kernel} of=${dst} bs=1k seek=${FLASH_KERNEL_OFFSET}
        dd if=${ddir}/${uinitrd} of=${dst} bs=1k seek=${FLASH_INITRD_OFFSET}
-- 
2.7.1




More information about the openbmc mailing list