All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2
@ 2016-02-24 18:40 OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 1/9] oe_mkimage: Use consistent indentation OpenBMC Patches
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

This series updates the build and init scripts to allow, nee require, that the rwfs be a jffs2 instead of our former ext4 filesystem.  

An kernel command line parameter clean-rwfs-filesystem, is also detected to clean the filesystem back to the whitelisted files.

The init and update scripts now use blkid to detect known filesystems, and assume jffs2 if blkid produces no output (as there is no current probe for jffs2).  The erased nor is also considered jffs2 and the kernel is happy to mount and use such a flash partition.

The requirement can be turned off with a 1 word edit to a flag in the init script.  Another flag can be
set to allow images to be built into an initrd for netboot updating.  Images can also be downloaded at the debug-init-sh sulogin shell if that is set in the command line.

The build system now initializes the image to 0xFF, the nor erase value, to allow the filesystem to be implicit.

There is also a  correction to an error path takeover message.
I have exercised all paths of the final init script.

https://github.com/openbmc/openbmc/pull/189

Andrew Jeffery (6):
  oe_mkimage: Use consistent indentation
  obmc-init.sh: Fix FS type in mount failure message
  obmc-{init,update}.sh: Cope with alternate RW FS types
  openbmc: Generate images with empty NOR sections in the erased state
  openbmc: Lift mkfs opts to variables and use OVERRIDES capability
  openbmc: Switch RW FS from ext4 to jffs2

Milton D. Miller II (1):
  initfs: Use stty to drain output before reboot

Milton Miller (2):
  initfs: Do not warn on missing jffs2 fsck
  initfs: Add flash clear and update during init

 meta-phosphor/classes/image-overlay.bbclass        |  2 +-
 .../obmc-phosphor-image_types_uboot.bbclass        | 31 +++++++--
 .../obmc-phosphor-initfs/files/obmc-init.sh        | 75 ++++++++++++++++++++--
 .../obmc-phosphor-initfs/files/obmc-shutdown.sh    |  2 +
 .../obmc-phosphor-initfs/files/obmc-update.sh      | 19 +++++-
 5 files changed, 115 insertions(+), 14 deletions(-)

-- 
2.7.1

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH openbmc 1/9] oe_mkimage: Use consistent indentation
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 2/9] obmc-init.sh: Fix FS type in mount failure message OpenBMC Patches
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

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

It was inconsistent with the rest of the file, which seems to use 7
spaces. In particular, vim-sleuth was detecting the indentation style
from the first indent(s) in the file, which were in the oe_mkimage
function.

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

diff --git a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
index c390c36..bf987bb 100644
--- a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
@@ -4,9 +4,9 @@ inherit image_types_uboot
 # the image load address and entry point. Override it here.
 
 oe_mkimage () {
-    mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk -C $2 -n ${IMAGE_BASENAME} \
-        -a ${INITRD_IMAGE_LOADADDRESS} -e ${INITRD_IMAGE_ENTRYPOINT} \
-        -d ${DEPLOY_DIR_IMAGE}/$1 ${DEPLOY_DIR_IMAGE}/$1.u-boot
+       mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk -C $2 -n ${IMAGE_BASENAME} \
+              -a ${INITRD_IMAGE_LOADADDRESS} -e ${INITRD_IMAGE_ENTRYPOINT} \
+              -d ${DEPLOY_DIR_IMAGE}/$1 ${DEPLOY_DIR_IMAGE}/$1.u-boot
 }
 
 INITRD_IMAGE_ENTRYPOINT ?= "0x40800000"
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 2/9] obmc-init.sh: Fix FS type in mount failure message
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 1/9] oe_mkimage: Use consistent indentation OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 3/9] obmc-{init, update}.sh: Cope with alternate RW FS types OpenBMC Patches
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

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

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 .../common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index 6750de3..9674765 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -114,7 +114,7 @@ then
 	msg="$(cat)" << HERE
 
 Mounting read-write $rwdev filesystem failed.  Please fix and run
-	mount $rwdev $rwdir -t $rwfs -o $rwopts
+	mount $rwdev $rwdir -t $rwfst -o $rwopts
 to to continue, or do change nothing to run from RAM for this boot.
 HERE
 	debug_takeover "$msg"
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 3/9] obmc-{init, update}.sh: Cope with alternate RW FS types
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 1/9] oe_mkimage: Use consistent indentation OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 2/9] obmc-init.sh: Fix FS type in mount failure message OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 4/9] openbmc: Generate images with empty NOR sections in the erased state OpenBMC Patches
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

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

Busybox's blkid is a little hamstrung, requiring some processing of the
output to emulate what can be achieved with a couple of options with
blkid from util-linux.

Similar to findmtd(), the code for probe_fs_type() and blkid_fs_type()
is duplicated between obmc-{init,update}.sh. Some consideration should
be given to splitting out common functionality into well-defined
sourcable scripts.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 .../obmc-phosphor-initfs/files/obmc-init.sh           | 16 +++++++++++++++-
 .../obmc-phosphor-initfs/files/obmc-update.sh         | 19 ++++++++++++++++---
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index 9674765..7fc6587 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -30,6 +30,20 @@ findmtd() {
 	echo $m
 }
 
+blkid_fs_type() {
+	# Emulate util-linux's `blkid -s TYPE -o value $1`
+	# Example busybox blkid output:
+	#    # blkid /dev/mtdblock5
+	#    /dev/mtdblock5: TYPE="squashfs"
+	# Process output to extract TYPE value "squashfs".
+	blkid $1 | sed -e 's/^.*TYPE="//' -e 's/".*$//'
+}
+
+probe_fs_type() {
+	fst=$(blkid_fs_type $1)
+	echo ${fst:=jffs2}
+}
+
 debug_takeover() {
 	echo "$@"
 	test -n "$@" && echo Enter password to try to manually fix.
@@ -72,7 +86,7 @@ rodev=/dev/mtdblock${rofs#mtd}
 rwdev=/dev/mtdblock${rwfs#mtd}
 
 rofst=squashfs
-rwfst=ext4
+rwfst=$(probe_fs_type $rwdev)
 roopts=ro
 rwopts=rw
 
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index face06d..367c302 100755
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -35,10 +35,23 @@ findmtd() {
 	echo $m
 }
 
+blkid_fs_type() {
+	# Emulate util-linux's `blkid -s TYPE -o value $1`
+	# Example busybox blkid output:
+	#    # blkid /dev/mtdblock5
+	#    /dev/mtdblock5: TYPE="squashfs"
+	# Process output to extract TYPE value "squashfs".
+	blkid $1 | sed -e 's/^.*TYPE="//' -e 's/".*$//'
+}
+
+probe_fs_type() {
+	fst=$(blkid_fs_type $1)
+	echo ${fst:=jffs2}
+}
+
 rwfs=$(findmtd rwfs)
 
 rwdev=/dev/mtdblock${rwfs#mtd}
-rwfst=ext4
 rwopts=rw
 rorwopts=ro${rwopts#rw}
 
@@ -50,7 +63,7 @@ if test -n "$rwfs" && test -s whitelist
 then
 
 	mkdir -p $rwdir
-	mount $rwdev $rwdir -t $rwfst -o $rorwopts
+	mount $rwdev $rwdir -t $(probe_fs_type $rwdev) -o $rorwopts
 
 	while read f
 	do
@@ -87,7 +100,7 @@ done
 
 if test -d $save
 then
-	mount $rwdev $rwdir -t $rwfst -o $rwopts
+	mount $rwdev $rwdir -t $(probe_fs_type $rwdev) -o $rwopts
 	cp -rp $save/. $upper/
 	umount $rwdir
 fi
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 4/9] openbmc: Generate images with empty NOR sections in the erased state
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
                   ` (2 preceding siblings ...)
  2016-02-24 18:40 ` [PATCH openbmc 3/9] obmc-{init, update}.sh: Cope with alternate RW FS types OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 5/9] openbmc: Lift mkfs opts to variables and use OVERRIDES capability OpenBMC Patches
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

From: Andrew Jeffery <andrew@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@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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 5/9] openbmc: Lift mkfs opts to variables and use OVERRIDES capability
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
                   ` (3 preceding siblings ...)
  2016-02-24 18:40 ` [PATCH openbmc 4/9] openbmc: Generate images with empty NOR sections in the erased state OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 6/9] openbmc: Switch RW FS from ext4 to jffs2 OpenBMC Patches
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

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

Moves the ext4-specific mkfs options out to configuration variables.
OVERLAY_MKFS_OPTS can be overridden using the usual bitbake OVERRIDES
mechanism, where the override postfix is 'rwfs-${OVERLAY_BASETYPE}',
e.g. rwfs-ext4.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 .../classes/obmc-phosphor-image_types_uboot.bbclass        | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
index 96193a3..adb86e0 100644
--- a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass
@@ -23,6 +23,14 @@ FLASH_ROFS_OFFSET ?= "4864"
 FLASH_RWFS_OFFSET ?= "28672"
 RWFS_SIZE ?= "4096"
 
+# Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However,
+# avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are
+# reserved for the primary image (and setting them currently breaks the build).
+# Instead, prefix the overlay override value with 'rwfs-' to avoid collisions.
+DISTROOVERRIDES .= ":rwfs-${OVERLAY_BASETYPE}"
+
+OVERLAY_MKFS_OPTS_rwfs-ext4 = "-b 4096 -F -O^huge_file"
+
 # $(( ${FLASH_SIZE} - ${FLASH_RWFS_OFFSET} ))
 
 # IMAGE_POSTPROCESS_COMMAND += "do_generate_flash"
@@ -58,8 +66,12 @@ do_generate_flash() {
        fi
 
        oe_mkimage  "${initrd}" "${INITRD_CTYPE}" || bbfatal "oe_mkimage initrd"
+
        mk_nor_image ${ddir}/${rwfs} ${RWFS_SIZE}
-       mkfs.${OVERLAY_BASETYPE} -b 4096 -F -O^huge_file ${ddir}/${rwfs} || bbfatal "mkfs rwfs"
+       if [ "${OVERLAY_BASETYPE}" != jffs2 ]; then
+              mkfs.${OVERLAY_BASETYPE} ${OVERLAY_MKFS_OPTS} ${ddir}/${rwfs} || \
+                     bbfatal "mkfs rwfs"
+       fi
 
        dst="${ddir}/${FLASH_IMAGE_NAME}"
        rm -rf $dst
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 6/9] openbmc: Switch RW FS from ext4 to jffs2
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
                   ` (4 preceding siblings ...)
  2016-02-24 18:40 ` [PATCH openbmc 5/9] openbmc: Lift mkfs opts to variables and use OVERRIDES capability OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 7/9] initfs: Do not warn on missing jffs2 fsck OpenBMC Patches
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

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

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 meta-phosphor/classes/image-overlay.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta-phosphor/classes/image-overlay.bbclass b/meta-phosphor/classes/image-overlay.bbclass
index 1c6137d..8997aae 100644
--- a/meta-phosphor/classes/image-overlay.bbclass
+++ b/meta-phosphor/classes/image-overlay.bbclass
@@ -3,7 +3,7 @@ INITRD_IMAGE ?= "core-image-minimal-initramfs"
 INITRD ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.${INITRD_CTYPE}${uboot}"
 
 IMAGE_BASETYPE ?= "squashfs-xz"
-OVERLAY_BASETYPE ?= "ext4"
+OVERLAY_BASETYPE ?= "jffs2"
 
 IMAGE_TYPES_${PN} += "${IMAGE_BASETYPE}"
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 7/9] initfs: Do not warn on missing jffs2 fsck
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
                   ` (5 preceding siblings ...)
  2016-02-24 18:40 ` [PATCH openbmc 6/9] openbmc: Switch RW FS from ext4 to jffs2 OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-25  1:14   ` Andrew Jeffery
  2016-02-24 18:40 ` [PATCH openbmc 8/9] initfs: Add flash clear and update during init OpenBMC Patches
  2016-02-24 18:40 ` [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot OpenBMC Patches
  8 siblings, 1 reply; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

We know there is no command and we plan to have this the default.

Suppress the message to avoid user questions and concerns.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index 7fc6587..f2fe938 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -119,7 +119,8 @@ then
 	then
 		debug_takeover "fsck of read-write fs on $rwdev failed (rc=$rc)"
 	fi
-else
+elif test $fsck != /sbin/fsck.jffs2
+then
 	echo "No '$fsck' in read only fs, skipping fsck."
 fi
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 8/9] initfs: Add flash clear and update during init
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
                   ` (6 preceding siblings ...)
  2016-02-24 18:40 ` [PATCH openbmc 7/9] initfs: Do not warn on missing jffs2 fsck OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-25 10:42   ` Andrew Jeffery
  2016-02-25 23:51   ` Milton Miller II
  2016-02-24 18:40 ` [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot OpenBMC Patches
  8 siblings, 2 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

From: Milton Miller <miltonm@us.ibm.com>

Add code to clear the rwfs (preserving files from the whitelist)
during init, by a command line option.

Also allow it to be triggered by the file system not being a jffs2.

A console user can download images to /run/initramfs/ at the
debug-init-sh prompt for manual update.

Also add code but do not enable detecting images loaded into
initramfs / for future update options.  If enabled a custom initrd
with update images can be bulit (it would not fit in flash and
need to be netbooted).

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-init.sh        | 54 +++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index f2fe938..12c5a2f 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -85,13 +85,21 @@ rwfs=$(findmtd rwfs)
 rodev=/dev/mtdblock${rofs#mtd}
 rwdev=/dev/mtdblock${rwfs#mtd}
 
+# Set to y for yes, anything else for no.
+force_rwfst_jffs2=y
+flash_images_before_init=n
+
 rofst=squashfs
 rwfst=$(probe_fs_type $rwdev)
 roopts=ro
 rwopts=rw
 
+image=/run/initramfs/image-
+trigger=${image}rwfs
+
 init=/sbin/init
-fsck=/sbin/fsck.$rwfst
+fsckbase=/sbin/fsck.
+fsck=$fsckbase$rwfst
 fsckopts=-a
 
 echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
@@ -101,6 +109,50 @@ then
 	debug_takeover "Debug initial shell requested by command line."
 fi
 
+# If there are images in root move them to run/initramfs/ now.
+imagebasename=${image##*/}
+if test -n "${imagebasename}" -a "x$flash_images_before_init" = xy &&
+	ls /${imagebasename}* > /dev/null 2>&1
+then
+	echo "Pending flash updates found."
+	mv /${imagebasename}* ${image%$imagebasename}
+fi
+
+if grep -w clean-rwfs-filesystem /proc/cmdline
+then
+	echo "Cleaning of read-write overlay filesystem requested."
+	touch $trigger
+fi
+
+if test "x$force_rwfst_jffs2" = xy -a $rwfst != jffs2 -a ! -f $trigger
+then
+	echo "Converting read-write overlay filesystem to jffs2 forced."
+	touch $trigger
+fi
+
+if ls $image* > /dev/null 2>&1
+then
+	if ! test -x /update
+	then
+		debug_takeover "Flash update requested but /update missing!"
+	elif test -f $trigger -a ! -s $trigger
+	then
+		echo "Saving selected files from read-write overlay filesystem."
+		/update && rm -f $image*
+		echo "Clearing read-write overlay filesystem."
+		flash_eraseall /dev/$rwfs
+		echo "Restoring saved files to read-write overlay filesystem."
+		touch $trigger
+		/update 
+		rm -rf /save $trigger
+	else
+		/update && rm -f $image*
+	fi
+
+	rwfst=$(probe_fs_type $rwdev)
+	fsck=$fsckbase$rwfst
+fi
+
 mount $rodev $rodir -t $rofst -o $roopts
 
 if test -x $rodir$fsck
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot
  2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
                   ` (7 preceding siblings ...)
  2016-02-24 18:40 ` [PATCH openbmc 8/9] initfs: Add flash clear and update during init OpenBMC Patches
@ 2016-02-24 18:40 ` OpenBMC Patches
  2016-02-25  4:14   ` Andrew Jeffery
  2016-02-25 23:55   ` Milton Miller II
  8 siblings, 2 replies; 15+ messages in thread
From: OpenBMC Patches @ 2016-02-24 18:40 UTC (permalink / raw)
  To: openbmc

From: "Milton D. Miller II" <miltonm@us.ibm.com>

To see all the messages during shutdown call stty cooked.

A side effect of setting any mode is it will call ioctl(TIOC_DRAIN)
to drain the buffers first without regard to any change in the mode.

Shutdown and flash update now show the final ouptut and "Rebooting"
message before the reboot system call.

Before:
+ set +x
Remaining mounts:
tmpfs / tmpfs rw,nosuid,nodev,mode=755 0 0
dev /dev devtmpfs rw,relatime,size=126384k,nr_inodes=31596,mode=755 0 0
proc /proc proc rw,relatime 0 0
sys /s

U-Boot 2013.07 (Feb 23 2016 - 10:21:23)

After:
+ set +x
Remaining mounts:
tmpfs / tmpfs rw,nosuid,nodev,mode=755 0 0
dev /dev devtmpfs rw,relatime,size=126384k,nr_inodes=31596,mode=755 0 0
proc /proc proc rw,relatime 0 0
sys /sys sysfs rw,relatime 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
reboot: Restarting system

U-Boot 2013.07 (Feb 23 2016 - 10:21:23)

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
---
 .../common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
index 3eff1ea..fc359c5 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
@@ -47,6 +47,8 @@ cat /proc/mounts
 
 test "umount_proc" && umount /proc && rmdir /proc
 
+# ioctl(TIOC_DRAIN) to drain tty messages to console
+test -t 1 && stty cooked 0<&1
 
 # Execute the command systemd told us to ...
 if test -d /oldroot  && test "$1"
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH openbmc 7/9] initfs: Do not warn on missing jffs2 fsck
  2016-02-24 18:40 ` [PATCH openbmc 7/9] initfs: Do not warn on missing jffs2 fsck OpenBMC Patches
@ 2016-02-25  1:14   ` Andrew Jeffery
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Jeffery @ 2016-02-25  1:14 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc

[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]

On Wed, 2016-02-24 at 12:40 -0600, OpenBMC Patches wrote:
> From: Milton Miller <miltonm@us.ibm.com>
> 
> We know there is no command and we plan to have this the default.
> 
> Suppress the message to avoid user questions and concerns.
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
>  .../common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh    | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index 7fc6587..f2fe938 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -119,7 +119,8 @@ then
>  > 	> then
>  > 	> 	> debug_takeover "fsck of read-write fs on $rwdev failed (rc=$rc)"
>  > 	> fi
> -else
> +elif test $fsck != /sbin/fsck.jffs2

This is fairly minor, but would it be better to test $rwfst rather than
the path? Otherwise we're hardcoding '/sbin/fsck.' in two places (not
that I expect it to change). The filesystem type is the differentiating
factor here, and it's jffs2 that has no fsck (i.e. we don't expect it
to exist anywhere, let alone a different path). So maybe:

    elif test $rwfst != jffs2

Thoughts?

Otherwise:

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>

> +then
>  > 	> echo "No '$fsck' in read only fs, skipping fsck."
>  fi
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot
  2016-02-24 18:40 ` [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot OpenBMC Patches
@ 2016-02-25  4:14   ` Andrew Jeffery
  2016-02-25 23:55   ` Milton Miller II
  1 sibling, 0 replies; 15+ messages in thread
From: Andrew Jeffery @ 2016-02-25  4:14 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc

[-- Attachment #1: Type: text/plain, Size: 2620 bytes --]

On Wed, 2016-02-24 at 12:40 -0600, OpenBMC Patches wrote:
> From: "Milton D. Miller II" <miltonm@us.ibm.com>
> 
> To see all the messages during shutdown call stty cooked.
> 
> A side effect of setting any mode is it will call ioctl(TIOC_DRAIN)

So due to past indiscretions and increasing my own understanding I
tried to follow this up. Seems that:

* TIOC_DRAIN doesn't appear to be a thing?
* Google knows more about TIOCDRAIN, but not a lot?
* TCSADRAIN might be more useful to mention here?

If I were to follow it up the TIOC_DRAIN , where should I look?

Should this part of the commit message be changed?

However, I've followed the busybox stty implementation to the point of
calling tcsetattr(..., TCSADRAIN, ...), so the change looks like it
should do what we want. Also you've documented testing it below, so
that helps :)

> to drain the buffers first without regard to any change in the mode.
> 
> Shutdown and flash update now show the final ouptut

typo: output

Otherwise,

Acked-by: Andrew Jeffery <andrew@aj.id.au>

>  and "Rebooting"
> message before the reboot system call.
> 
> Before:
> + set +x
> Remaining mounts:
> tmpfs / tmpfs rw,nosuid,nodev,mode=755 0 0
> dev /dev devtmpfs rw,relatime,size=126384k,nr_inodes=31596,mode=755 0 0
> proc /proc proc rw,relatime 0 0
> sys /s
> 
> U-Boot 2013.07 (Feb 23 2016 - 10:21:23)
> 
> After:
> + set +x
> Remaining mounts:
> tmpfs / tmpfs rw,nosuid,nodev,mode=755 0 0
> dev /dev devtmpfs rw,relatime,size=126384k,nr_inodes=31596,mode=755 0 0
> proc /proc proc rw,relatime 0 0
> sys /sys sysfs rw,relatime 0 0
> tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
> reboot: Restarting system
> 
> U-Boot 2013.07 (Feb 23 2016 - 10:21:23)
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
>  .../common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> index 3eff1ea..fc359c5 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh
> @@ -47,6 +47,8 @@ cat /proc/mounts
>  
>  test "umount_proc" && umount /proc && rmdir /proc
>  
> +# ioctl(TIOC_DRAIN) to drain tty messages to console
> +test -t 1 && stty cooked 0<&1
>  
>  # Execute the command systemd told us to ...
>  if test -d /oldroot  && test "$1"

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH openbmc 8/9] initfs: Add flash clear and update during init
  2016-02-24 18:40 ` [PATCH openbmc 8/9] initfs: Add flash clear and update during init OpenBMC Patches
@ 2016-02-25 10:42   ` Andrew Jeffery
  2016-02-25 23:51   ` Milton Miller II
  1 sibling, 0 replies; 15+ messages in thread
From: Andrew Jeffery @ 2016-02-25 10:42 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc

[-- Attachment #1: Type: text/plain, Size: 3957 bytes --]

On Wed, 2016-02-24 at 12:40 -0600, OpenBMC Patches wrote:
> From: Milton Miller <miltonm@us.ibm.com>
> 
> Add code to clear the rwfs (preserving files from the whitelist)
> during init, by a command line option.
> 
> Also allow it to be triggered by the file system not being a jffs2.

So this helps avoid a two-stage upgrade process right? We write a new
(fixed wrt spi-nor) image-kernel and an updated image-initrd, reboot,
and then have obmc-init.sh switch the rwfs partition to JFFS2. Is this
worth mentioning?

A cleaning function seems useful; did you give any thought to a factory
-reset function (i.e. not preserving the whitelist files)? I don't
think this is covered either here or in obmc-update.sh? Avoiding pflash
would be nice but it's probably a separate problem.

Otherwise:

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>

> 
> A console user can download images to /run/initramfs/ at the
> debug-init-sh prompt for manual update.
> 
> Also add code but do not enable detecting images loaded into
> initramfs / for future update options.  If enabled a custom initrd
> with update images can be bulit (it would not fit in flash and
> need to be netbooted).
> 
> Signed-off-by: Milton Miller <miltonm@us.ibm.com>
> ---
>  .../obmc-phosphor-initfs/files/obmc-init.sh        | 54 +++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> index f2fe938..12c5a2f 100644
> --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
> @@ -85,13 +85,21 @@ rwfs=$(findmtd rwfs)
>  rodev=/dev/mtdblock${rofs#mtd}
>  rwdev=/dev/mtdblock${rwfs#mtd}
>  
> +# Set to y for yes, anything else for no.
> +force_rwfst_jffs2=y
> +flash_images_before_init=n
> +
>  rofst=squashfs
>  rwfst=$(probe_fs_type $rwdev)
>  roopts=ro
>  rwopts=rw
>  
> +image=/run/initramfs/image-
> +trigger=${image}rwfs
> +
>  init=/sbin/init
> -fsck=/sbin/fsck.$rwfst
> +fsckbase=/sbin/fsck.
> +fsck=$fsckbase$rwfst
>  fsckopts=-a
>  
>  echo rofs = $rofs $rofst   rwfs = $rwfs $rwfst
> @@ -101,6 +109,50 @@ then
>  > 	> debug_takeover "Debug initial shell requested by command line."
>  fi
>  
> +# If there are images in root move them to run/initramfs/ now.
> +imagebasename=${image##*/}
> +if test -n "${imagebasename}" -a "x$flash_images_before_init" = xy &&
> +> 	> ls /${imagebasename}* > /dev/null 2>&1
> +then
> +> 	> echo "Pending flash updates found."
> +> 	> mv /${imagebasename}* ${image%$imagebasename}
> +fi
> +
> +if grep -w clean-rwfs-filesystem /proc/cmdline
> +then
> +> 	> echo "Cleaning of read-write overlay filesystem requested."
> +> 	> touch $trigger
> +fi
> +
> +if test "x$force_rwfst_jffs2" = xy -a $rwfst != jffs2 -a ! -f $trigger
> +then
> +> 	> echo "Converting read-write overlay filesystem to jffs2 forced."
> +> 	> touch $trigger
> +fi
> +
> +if ls $image* > /dev/null 2>&1
> +then
> +> 	> if ! test -x /update
> +> 	> then
> +> 	> 	> debug_takeover "Flash update requested but /update missing!"
> +> 	> elif test -f $trigger -a ! -s $trigger
> +> 	> then
> +> 	> 	> echo "Saving selected files from read-write overlay filesystem."
> +> 	> 	> /update && rm -f $image*
> +> 	> 	> echo "Clearing read-write overlay filesystem."
> +> 	> 	> flash_eraseall /dev/$rwfs
> +> 	> 	> echo "Restoring saved files to read-write overlay filesystem."
> +> 	> 	> touch $trigger
> +> 	> 	> /update 
> +> 	> 	> rm -rf /save $trigger
> +> 	> else
> +> 	> 	> /update && rm -f $image*
> +> 	> fi
> +
> +> 	> rwfst=$(probe_fs_type $rwdev)
> +> 	> fsck=$fsckbase$rwfst
> +fi
> +
>  mount $rodev $rodir -t $rofst -o $roopts
>  
>  if test -x $rodir$fsck

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH openbmc 8/9] initfs: Add flash clear and update during init
  2016-02-24 18:40 ` [PATCH openbmc 8/9] initfs: Add flash clear and update during init OpenBMC Patches
  2016-02-25 10:42   ` Andrew Jeffery
@ 2016-02-25 23:51   ` Milton Miller II
  1 sibling, 0 replies; 15+ messages in thread
From: Milton Miller II @ 2016-02-25 23:51 UTC (permalink / raw)
  To: andrew; +Cc: OpenBMC Patches, openbmc

[-- Attachment #1: Type: text/html, Size: 2684 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot
  2016-02-24 18:40 ` [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot OpenBMC Patches
  2016-02-25  4:14   ` Andrew Jeffery
@ 2016-02-25 23:55   ` Milton Miller II
  1 sibling, 0 replies; 15+ messages in thread
From: Milton Miller II @ 2016-02-25 23:55 UTC (permalink / raw)
  To: andrew; +Cc: OpenBMC Patches, openbmc

[-- Attachment #1: Type: text/html, Size: 2560 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-02-25 23:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-24 18:40 [PATCH openbmc 0/9] Change Read/Write overlay filesystem to jffs2 OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 1/9] oe_mkimage: Use consistent indentation OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 2/9] obmc-init.sh: Fix FS type in mount failure message OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 3/9] obmc-{init, update}.sh: Cope with alternate RW FS types OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 4/9] openbmc: Generate images with empty NOR sections in the erased state OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 5/9] openbmc: Lift mkfs opts to variables and use OVERRIDES capability OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 6/9] openbmc: Switch RW FS from ext4 to jffs2 OpenBMC Patches
2016-02-24 18:40 ` [PATCH openbmc 7/9] initfs: Do not warn on missing jffs2 fsck OpenBMC Patches
2016-02-25  1:14   ` Andrew Jeffery
2016-02-24 18:40 ` [PATCH openbmc 8/9] initfs: Add flash clear and update during init OpenBMC Patches
2016-02-25 10:42   ` Andrew Jeffery
2016-02-25 23:51   ` Milton Miller II
2016-02-24 18:40 ` [PATCH openbmc 9/9] initfs: Use stty to drain output before reboot OpenBMC Patches
2016-02-25  4:14   ` Andrew Jeffery
2016-02-25 23:55   ` Milton Miller II

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.