From cbc74ac23f1594d4fd2022cc552e7ebf60a64c82 Mon Sep 17 00:00:00 2001 From: Saqib Khan Date: Thu, 10 Aug 2017 11:24:38 -0500 Subject: BMC: Mount ubi volume on BMC reboot - Create a static service file that will be run on all BMC boot to remount the bmc ubi volume. - Read the ubinfo for all available volumes from obmc-flash-bmc script. - Re-Mount the available volumes on /media/ dir using the volume names. Change-Id: I8f3a0b41257927fa0e69001278cc836ba0a52dda Signed-off-by: Saqib Khan --- .../flash/phosphor-software-manager.bb | 1 + .../flash/phosphor-software-manager/obmc-flash-bmc | 40 ++++++++++++++++++++++ .../obmc-flash-bmc-ubiremount.service | 12 +++++++ 3 files changed, 53 insertions(+) create mode 100644 meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service (limited to 'meta-phosphor/common/recipes-phosphor/flash') diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb index ef8d30e8e..96a66e20b 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb @@ -72,6 +72,7 @@ SYSTEMD_SERVICE_${PN}-updater += " \ obmc-flash-bmc-ubirw-remove.service \ obmc-flash-bmc-ubiro-remove@.service \ usr-local.mount \ + obmc-flash-bmc-ubiremount.service \ " # Name of the mtd device where the ubi volumes should be created 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 5c960f3b8..d17ee5c36 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 @@ -80,6 +80,43 @@ ubi_remove() { fi } +remount_ubi() { + # Get a list of all devices formatted as UBI + for file in /dev/mtd*; do + if [[ $(hexdump -C -n 3 $file) =~ "UBI" ]]; then + mtd="${file: -1}" + if [[ $mtd =~ ^-?[0-9]+$ ]]; then + mtds=${mtd},${mtds} + fi + fi + done + + IFS=',' read -r -a mtds <<< "$mtds" + mtds=($(echo "${mtds[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) + for mtd in ${mtds[@]}; do + # Re-attach mtd device to ubi if not already done + ubiattach /dev/ubi_ctrl -m "${mtd}" -d "${mtd}" &> /dev/null + # Get information on all ubi volumes + ubinfo=$(ubinfo -d ${mtd}) + presentVolumes=${ubinfo##*:} + IFS=', ' read -r -a array <<< "$presentVolumes" + for element in ${array[@]}; do + elementProperties=$(ubinfo -d $mtd -n $element) + # Get ubi volume name by getting rid of additional properties + name=${elementProperties#*Name:} + name="${name%Character*}" + name="$(echo -e "${name}" | tr -d '[:space:]')" + + if [[ ${name} == ro-* ]]; then + mountdir="/media/${name}" + mkdir -p "${mountdir}" + ubiblock --create /dev/ubi${mtd}_${element} &> /dev/null + mount -t squashfs -o ro "/dev/ubiblock${mtd}_${element}" "${mountdir}" + fi + done + done +} + ubi_setenv() { varName="${variable%"\x3d"*}" value="${variable##*"\x3d"}" @@ -119,6 +156,9 @@ case "$1" in variable="$2" ubi_setenv ;; + ubiremount) + remount_ubi + ;; *) echo "Invalid argument" exit 1 diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service new file mode 100644 index 000000000..36b55516b --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-ubiremount.service @@ -0,0 +1,12 @@ +[Unit] +Description=Remount the ubi volume after a reboot +Wants=xyz.openbmc_project.Software.BMC.Updater.service +Before=xyz.openbmc_project.Software.BMC.Updater.service + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart={sbindir}/obmc-flash-bmc ubiremount + +[Install] +WantedBy=multi-user.target -- cgit v1.2.1