From 7e81e706a19a9f7e222bbde2431f22275c83476c Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 25 Aug 2023 16:24:18 +0200 Subject: [PATCH] recovery-initramfs: adapt format_ubi_volume() to new partition layout of ccmp1 The ccmp1 has two MTD partitions (UBI, UBI_2) with different system volumes. Previously, the fact of having two ubi devices was taken as proof of being on a multi-MTD system (one that has one UBI volume per partition). Instead, this commit reformulates the condition to having a partition of the same name than the UBI volume. For the case of the ccmp1, add a new for loop to iterate across any number of UBI devices. Signed-off-by: Hector Palacios --- .../recovery-initramfs-init | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 2008343ca..59d0e995d 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -231,21 +231,10 @@ format_ubi_volume() { psplash_message "Formatting '${1}' partition..." psplash_progress "0" - # If /dev/ubi1 exists is a system with multiple MTD partitions - if [ ! -c "/dev/ubi1" ]; then - # Find the volume number associated to the volume name - for d in /dev/ubi0_*; do - volname="$(ubinfo ${d} | grep ^Name | awk '{print $(2)}')" - if [ "${volname}" = "${1}" ]; then - # Find mountpoint - mountpoint="$(mount | grep ubi0:${1} | awk '{print $(3) }')" - umount ${mountpoint} 2> /dev/null - # Wipe out volume - ubiupdatevol ${d} -t - fi - done - psplash_progress "100" - else + # If the system is a multi-MTD, there must be an MTD partition by the + # same name as the UBI volume + result="$(grep '\"${1}\"$' /proc/mtd)" + if [ -n "${result}" ]; then # Find the MTD partition. local mtd_num="$(sed -ne "s/mtd\([0-9]\+\):.*\<${1}\>.*/\1/g;T;p" /proc/mtd 2>/dev/null)" if [ -z "${mtd_num}" ]; then @@ -280,6 +269,24 @@ format_ubi_volume() { quit_with_error "Error creating '${1}' UBI volume" fi fi + else + # Find the volume number associated to the volume name + ubidevs="$(ls /dev/ubi* | grep 'ubi[0-9]\+$')" + for d in $ubidevs;do + for v in "${d}"_*; do + volname="$(ubinfo ${v} | grep ^Name | awk '{print $(2)}')" + if [ "${volname}" = "${1}" ]; then + # Find mountpoint + u="$(basename ${d})" + mountpoint="$(mount | grep ${u}:${1} | awk '{print $(3) }')" + umount ${mountpoint} 2> /dev/null + # Wipe out volume + ubiupdatevol ${v} -t + break 2 + fi + done + done + psplash_progress "100" fi }