summaryrefslogtreecommitdiff
path: root/meta-phosphor/recipes-phosphor/initrdscripts
diff options
context:
space:
mode:
Diffstat (limited to 'meta-phosphor/recipes-phosphor/initrdscripts')
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh26
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init.bb27
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh66
3 files changed, 112 insertions, 7 deletions
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh b/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
index 62be89f03..e61ede911 100644
--- a/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/files/obmc-init.sh
@@ -128,18 +128,25 @@ try_wget() {
debug_takeover() {
echo "$@"
- test -n "$@" && echo Enter password to try to manually fix.
+
+ if ! grep -w enable-initrd-debug-sh "$optfile"
+ then
+ echo "Fatal error, triggering kernel panic!"
+ exit 1
+ fi
+
+ test -n "$@" && echo Try to manually fix.
cat << HERE
After fixing run exit to continue this script, or reboot -f to retry, or
touch /takeover and exit to become PID 1 allowing editing of this script.
HERE
- while ! sulogin && ! test -f /takeover
+ while ! /bin/sh && ! test -f /takeover
do
- echo getty failed, retrying
+ echo /bin/sh failed, retrying
done
- # Touch /takeover in the above getty to become pid 1
+ # Touch /takeover in the above shell to become pid 1
if test -e /takeover
then
cat << HERE
@@ -208,7 +215,12 @@ echo rofs = $rofs $rofst rwfs = $rwfs $rwfst
if grep -w debug-init-sh $optfile
then
- debug_takeover "Debug initial shell requested by command line."
+ if grep -w enable-initrd-debug-sh "$optfile"
+ then
+ debug_takeover "Debug initial shell requested by command line."
+ else
+ echo "Need to also add enable-initrd-debug-sh for debug shell."
+ fi
fi
if test "x$consider_download_files" = xy &&
@@ -394,7 +406,7 @@ then
Mounting read-write $rwdev filesystem failed. Please fix and run
mount $rwdev $rwdir -t $rwfst -o $rwopts
-to to continue, or do change nothing to run from RAM for this boot.
+or perform a factory reset with the clean-rwfs-filesystem option.
HERE
debug_takeover "$msg"
fi
@@ -411,7 +423,7 @@ do
Unable to confirm /sbin/init is an executable non-empty file
in merged file system mounted at /root.
-Change Root test failed! Invoking emergency shell.
+Change Root test failed!
HERE
debug_takeover "$msg"
done
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init.bb b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init.bb
new file mode 100644
index 000000000..0c7a88cd9
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init.bb
@@ -0,0 +1,27 @@
+SUMMARY = "Phosphor OpenBMC pre-init scripts for mmc"
+DESCRIPTION = "Phosphor OpenBMC filesystem mount implementation for mmc."
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+PR = "r1"
+
+inherit allarch
+
+RDEPENDS_${PN} += " \
+ ${VIRTUAL-RUNTIME_base-utils} \
+ e2fsprogs-e2fsck \
+ gptfdisk \
+ parted \
+ udev \
+"
+
+S = "${WORKDIR}"
+SRC_URI += "file://mmc-init.sh"
+
+do_install() {
+ install -m 0755 ${WORKDIR}/mmc-init.sh ${D}/init
+ install -d ${D}/dev
+ mknod -m 622 ${D}/dev/console c 5 1
+}
+
+FILES_${PN} += " /init /dev "
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
new file mode 100644
index 000000000..061757519
--- /dev/null
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Get the value of the root env variable found in /proc/cmdline
+get_root() {
+ local root="$(cat /proc/cmdline)"
+ root="${root##* root=PARTLABEL=}"
+ root="${root%% *}"
+ [ "${root}" != "" ] && echo "${root}"
+}
+
+fslist="proc sys dev run"
+rodir=/mnt/rofs
+cd /
+mkdir -p $fslist
+mount dev dev -tdevtmpfs
+mount sys sys -tsysfs
+mount proc proc -tproc
+mount tmpfs run -t tmpfs -o mode=755,nodev
+
+# Wait up to 5s for the mmc device to appear. Continue even if the count is
+# exceeded. A failure will be caught later like in the mount command.
+mmcdev="/dev/mmcblk0"
+count=0
+while [ $count -lt 5 ]; do
+ if [ -e "${mmcdev}" ]; then
+ break
+ fi
+ sleep 1
+ count=$((count + 1))
+done
+
+# Move the secondary GPT to the end of the device if needed. Look for the GPT
+# header signature "EFI PART" located 512 bytes from the end of the device.
+magic=$(tail -c 512 "${mmcdev}" | hexdump -C -n 8 | grep "EFI PART")
+if test -z "${magic}"; then
+ sgdisk -e "${mmcdev}"
+ partprobe
+fi
+
+# There eMMC GPT labels for the rootfs are rofs-a and rofs-b, and the label for
+# the read-write partition is rwfs. Run udev to make the partition labels show
+# up. Mounting by label allows for partition numbers to change if needed.
+udevd --daemon
+udevadm trigger --type=devices --action=add
+udevadm settle --timeout=10
+
+mkdir -p $rodir
+if ! mount /dev/disk/by-partlabel/"$(get_root)" $rodir -t ext4 -o ro; then
+ /bin/sh
+fi
+
+rwfsdev="/dev/disk/by-partlabel/rwfs"
+fsck.ext4 -p "${rwfsdev}"
+if ! mount "${rwfsdev}" $rodir/var -t ext4 -o rw; then
+ /bin/sh
+fi
+
+rm -rf $rodir/var/persist/etc-work/
+mkdir -p $rodir/var/persist/etc $rodir/var/persist/etc-work $rodir/var/persist/home/root
+mount overlay $rodir/etc -t overlay -o lowerdir=$rodir/etc,upperdir=$rodir/var/persist/etc,workdir=$rodir/var/persist/etc-work
+
+for f in $fslist; do
+ mount --move $f $rodir/$f
+done
+
+exec chroot $rodir /sbin/init