Lines Matching +full:systemd +full:- +full:resolved
2 set -eo pipefail
10 if [ -z "${m}" ]; then
27 m="$(grep -xl "$1" /sys/class/mtd/*/name)"
42 u="$(grep -xl "$1" /sys/class/ubi/ubi?/subsystem/ubi*/name)"
50 u="$(grep -xl "$1" /sys/class/ubi/ubi"$2"/subsystem/ubi"$2"*/name)"
58 u="$(grep -h "$1" /sys/class/ubi/ubi"$2"/subsystem/ubi"$2"*/name)"
73 busctl set-property xyz.openbmc_project.Software.Manager \
77 busctl set-property xyz.openbmc_project.Software.BMC.Updater \
83 # Set the u-boot envs that perform a side switch on failure to boot
88 fw_setenv obmc_bootcmd "ubi part obmc-ubi; run do_rwreset; ubi read \
99 rootversion="${rootname##*-}"
100 rootkernel="kernel-${rootversion}"
105 rmnames="$(findubiname_onmtd "${name%-*}-" "${ro}")"
106 mapfile -t array <<< "${rmnames}"
108 while [ "${ubicount}" -ge "${keepmax}" ]; do
112 rmversion="${rmname##*-}"
114 rmubi="$(findubi_onmtd "rofs-${rmversion}" "${ro}")"
117 ubi_remove "rofs-${rmversion}" "${ro}"
118 ubi_remove "kernel-${rmversion}" "${ro}"
125 (( ubicount-- ))
135 if [ -n "$imgsize" ]; then
136 rwsize="$(fw_printenv -n rwfs_size 2>/dev/null)" || true
143 if [ -z "${vol}" ]; then
144 ubimkvol "${ubidev}" -N "${name}" -s "${imgsize}"
154 # Request to use alternate mtd device, choose the non-root one
166 if [ -z "${imgfile}" ]; then
167 echo "Unable to create read-only volume. Image file not specified."
173 imgsize="$(stat -c '%s' "${img}")"
176 if [ -n "${vol}" ]; then
182 if [ -z "${vol}" ]; then
183 ubimkvol "${ubidev}" -N "${name}" -s "${imgsize}" --type=static
195 if [ ! -e "$block" ]; then
196 ubiblock --create "/dev/ubi${ubidevid}"
210 if [ -n "${rmmtd}" ]; then
216 if [ -n "$vol" ]; then
219 if grep -q "$rmname" /proc/mounts; then
220 mountdir=$(grep "$rmname" /proc/mounts | cut -d " " -f 2)
222 rm -r "$mountdir"
225 ubirmvol "/dev/${vol}" -N "$rmname"
231 activeVersion=$(busctl --list --no-pager tree \
233 grep /xyz/openbmc_project/software/ | tail -c 9)
235 if [[ -z "$activeVersion" ]]; then
236 activeVersion=$(busctl --list --no-pager tree \
238 grep /xyz/openbmc_project/software/ | tail -c 9)
241 if [[ -z "$activeVersion" ]]; then
242 vols=$(ubinfo -a | grep "rofs-" | cut -c 14-)
244 flashid=$(busctl get-property xyz.openbmc_project.Software.Manager \
246 xyz.openbmc_project.Common.FilePath Path | awk '{print $NF;}' | tr -d '"') ||
247 flashid=$(busctl get-property xyz.openbmc_project.Software.BMC.Updater \
249 xyz.openbmc_project.Common.FilePath Path | awk '{print $NF;}' | tr -d '"')
250 vols=$(ubinfo -a | grep "rofs-" | \
251 grep -v "$flashid" | cut -c 14-) || true
254 mapfile -t array <<< "${vols}"
261 altNum="$(findmtdnum "alt-bmc")"
262 if [ -n "${altNum}" ]; then
263 altRwfs=$(ubinfo -a -d "${altNum}" | grep -w "rwfs") || true
264 if [ -n "${altRwfs}" ]; then
266 mkdir -p "${altVarMount}"
267 if mount ubi"${altNum}":rwfs "${altVarMount}" -t ubifs -o defaults; then
268 mkdir -p "${altVarMount}"/persist/etc
276 altbmcmtd="$(findmtd "alt-bmc")"
277 mtds="${bmcmtd: -1}","${altbmcmtd: -1}"
282 IFS=',' read -r -a arrayMtds <<< "$mtds"
285 ubinfo=$(ubinfo -d "${mtd}")
287 IFS=', ' read -r -a array <<< "$presentVolumes"
289 elementProperties=$(ubinfo -d "$mtd" -n "$element")
293 name="$(echo -e "${name}" | tr -d '[:space:]')"
295 if [[ ${name} == rofs-* ]]; then
297 mountdir="/media/${name}-functional"
302 if [ ! -d "${mountdir}" ]; then
303 mkdir -p "${mountdir}"
304 # U-Boot will create the ubiblock for the running version, but not
306 if [ ! -e "/dev/ubiblock${mtd}_${element}" ]; then
307 ubiblock --create "/dev/ubi${mtd}_${element}"
309 mount -t squashfs -o ro "/dev/ubiblock${mtd}_${element}" "${mountdir}"
323 if [ -n "${altNum}" ]; then
325 mkdir -p "${altFsMount}"
327 mount -t "${typ}" "${altFsBlock}" "${altFsMount}"
340 value="$(fw_printenv -n "${varName}")"
341 fw_setenv -c /etc/alt_fw_env.config "${varName}" "${value}"
344 # When the alternate bmc chip boots, u-boot thinks its the primary mtdX.
346 # alternate bmc u-boot environment.
348 value="$(fw_printenv -n ubiblock)"
350 altNum="$(findmtdnum "alt-bmc")"
360 fw_setenv -c /etc/alt_fw_env.config ubiblock "${value}"
364 value="$(fw_printenv -n root)"
366 altNum="$(findmtdnum "alt-bmc")"
376 fw_setenv -c /etc/alt_fw_env.config root "${value}"
380 # The U-Boot environment maintains two banks of environment variables.
389 currentValue="$(fw_printenv -n "${varName}" 2>/dev/null)" || true
403 flashcp -v "${img}" /dev/"${flashmtd}"
413 vol="$(findubi rofs-"${flashid}")"
414 if [ -z "${vol}" ]; then
419 if [ ! -e "${block}" ]; then
422 ubi_setenv "kernelname=kernel-${flashid}"
427 #TODO: Replace the implementation with systemd-inhibitors lock
428 # once systemd/systemd#949 is resolved
430 dir="/run/systemd/system/"
431 file="reboot-guard.conf"
435 mkdir -p ${dir}"${unit}".target.d
436 echo -e "[Unit]\nRefuseManualStart=yes" >> ${dir}"${unit}".target.d/${file}
440 #TODO: Replace the implementation with systemd-inhibitors lock
441 # once systemd/systemd#949 is resolved
443 dir="/run/systemd/system/"
444 file="reboot-guard.conf"
448 rm -rf ${dir}"${unit}".target.d/${file}
454 alt="alt-bmc"
456 if [ -n "${altmtd}" ]; then
475 bmc="$(findmtd "u-boot")"
477 alt="$(findmtd "alt-u-boot")"
486 bmcenv="$(findmtd "u-boot-env")"
488 altenv="$(findmtd "alt-u-boot-env")"
491 echo "Mirroring U-boot to alt chip"
500 # Compare the device where u-boot resides with an image file. Specify the full
515 rm -f "${tmpFile}"
524 # The eMMC partition labels for the kernel and rootfs are boot-a/b and rofs-a/b.
534 if [[ $(readlink -f /dev/disk/by-partlabel/rofs-a) == "${root}" ]]; then
536 elif [[ $(readlink -f /dev/disk/by-partlabel/rofs-b) == "${root}" ]]; then
543 # The eMMC partition labels for the kernel and rootfs are boot-a/b and rofs-a/b.
544 # Return the label (a or b) for the non-running partition.
560 primaryDir="${mediaDir}/rofs-${primaryId}-functional"
561 secondaryDir="${mediaDir}/rofs-${secondaryId}"
565 if ! fsck.ext4 -p "/dev/disk/by-partlabel/rofs-${secondaryId}"; then
570 mkdir -p "${primaryDir}"
571 mkdir -p "${secondaryDir}"
573 mount PARTLABEL=rofs-"${primaryId}" "${primaryDir}" -t ext4 -o ro || rmdir "${primaryDir}"
574 mount PARTLABEL=rofs-"${secondaryId}" "${secondaryDir}" -t ext4 -o ro || rmdir "${secondaryDir}"
578 # Update u-boot if needed
581 imgUBoot="${imgpath}/${version}/image-u-boot"
588 # Update the secondary (non-running) boot and rofs partitions.
593 zstd -d -c "${imgpath}"/"${version}"/image-kernel | dd of="/dev/disk/by-partlabel/boot-${label}"
594 number="$(readlink -f /dev/disk/by-partlabel/boot-"${label}")"
596 sgdisk --change-name="${number}":boot-"${label}" /dev/mmcblk0 1>/dev/null
598 zstd -d -c "${imgpath}"/"${version}"/image-rofs | dd of="/dev/disk/by-partlabel/rofs-${label}"
599 number="$(readlink -f /dev/disk/by-partlabel/rofs-"${label}")"
601 sgdisk --change-name="${number}":rofs-"${label}" /dev/mmcblk0 1>/dev/null
608 if [ -f "${imgpath}"/"${version}"/image-hostfw ]; then
612 if [ -d "${patchdir}" ]; then
613 rm -rf "${patchdir:?}"/*
615 if grep -q "${hostfw_alt}" /proc/mounts; then
616 hostfw_alt=$(grep "${hostfw_alt}" /proc/mounts | cut -d " " -f 2)
619 hostfwdir=$(grep "hostfw " /proc/mounts | cut -d " " -f 2)
620 rm -f "${hostfwdir}/hostfw-${flashid}"
621 cp "${imgpath}"/"${version}"/image-hostfw "${hostfwdir}"/hostfw-"${label}"
622 mkdir -p "${hostfwdir}"/alternate
623 mount "${hostfwdir}"/hostfw-"${label}" "${hostfwdir}"/alternate -o ro
638 dd if=/dev/zero of=/dev/disk/by-partlabel/boot-"${flashid}" count=2048
639 dd if=/dev/zero of=/dev/disk/by-partlabel/rofs-"${flashid}" count=2048
649 # Get current boot device; 0-primary_bootdev device; 1 - alt_bootdev
668 echo "Mirroring U-boot to alt chip"
679 imgfile="image-u-boot"
689 reqmtd="$(echo "$2" | cut -d "+" -f 1)"
690 reqmtd2="$(echo "$2" | cut -d "+" -f 2)"
693 imgfile="image-rofs"
699 reqmtd="$(echo "$2" | cut -d "+" -f 1)"
700 reqmtd2="$(echo "$2" | cut -d "+" -f 2)"
703 imgfile="image-kernel"
743 mmc-mount)
747 mmc-remove)
751 mmc-setprimary)
755 mmc-mirroruboot)
758 static-altfs)
761 umount-static-altfs)