From ecf5269297443e7eb5e2b3d11c51302ece1da822 Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Tue, 11 Jul 2017 11:34:23 -0500 Subject: phosphor-software-manager: New service file to create ubi ro volumes Add service file and script to create ubi read-only volumes to store the rofs and kernel. Default the sizes to the current corresponding mtd size. Create a ubi block for the read-only image which is a squashfs. The mtd device locations can be passed through the recipe. Set it to the "pnor" mtd as the default. This can be changed via a per-system bbappend to other chips if desired, such as the alternate bmc chip. Resolves openbmc/openbmc#1651 Change-Id: I76aa9021a2bb5462c0e4c2efef99728d26873df0 Signed-off-by: Adriana Kobylak --- .../flash/phosphor-software-manager/obmc-flash-bmc | 50 ++++++++++++++++++++++ .../obmc-flash-bmc-ubiro@.service | 8 ++++ 2 files changed, 58 insertions(+) create mode 100644 meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiro@.service (limited to 'meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager') diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc index 16c5f3285..a45150327 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc @@ -28,12 +28,62 @@ ubi_rw() { fi } +ubi_ro() { + romtd="$(findmtd "${reqmtd}")" + ro="${romtd#mtd}" + ubidev="/dev/ubi${ro}" + + # Create a static ubi volume + # TODO Get the actual image size openbmc/openbmc#1840 + vol="$(findubi "${name}")" + if [ -z "${vol}" ]; then + ubimkvol "${ubidev}" -N "${name}" -s "${imgsize}" --type=static + vol="$(findubi "${name}")" + fi +} + +# Squashfs images need a ubi block +ubi_block() { + vol="$(findubi "${name}")" + ubidevid="${vol#ubi}" + block="/dev/ubiblock${ubidevid}" + if [ ! -e "$block" ]; then + ubiblock --create "/dev/ubi${ubidevid}" + fi +} + +ubi_updatevol() { + vol="$(findubi "${name}")" + ubidevid="${vol#ubi}" + img="/tmp/images/${version}/${imgfile}" + ubiupdatevol "/dev/ubi${ubidevid}" "${img}" +} + case "$1" in ubirw) reqmtd="$2" name="$3" ubi_rw ;; + ubiro) + reqmtd="$2" + name="$3" + version="$4" + imgfile="image-rofs" + imgsize="16MiB" + ubi_ro + ubi_block + ubi_updatevol + ;; + ubikernel) + reqmtd="$2" + name="$3" + version="$4" + imgfile="image-kernel" + imgsize="4MiB" + ubi_ro + ubi_updatevol + ;; *) echo "Invalid argument" exit 1 diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiro@.service b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiro@.service new file mode 100644 index 000000000..4dec96efb --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiro@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Create read-only ubi volumes %I + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart={sbindir}/obmc-flash-bmc ubiro {RO_MTD} ro-%i %i +ExecStart={sbindir}/obmc-flash-bmc ubikernel {KERNEL_MTD} kernel-%i %i -- cgit v1.2.1