diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2020-08-17 20:40:23 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2020-08-21 02:00:13 +0300 |
commit | 331a369594ce399c2b88775368f8631cd7d7a99f (patch) | |
tree | 230517a472a3fd7487f649901bb162b67f9e4131 /meta-phosphor/recipes-phosphor/initrdscripts | |
parent | 24ed9c7fcc5bd79b7d69b6d725816fb5eace6e08 (diff) | |
download | openbmc-331a369594ce399c2b88775368f8631cd7d7a99f.tar.xz |
mmc-init.sh: Wait for mmc device
The initramfs was accessing the mmc device before it was probed
in some cases, leading to this error message:
[ 4.412464] mmcblk0rpmb: mmc0:0001 R1J56L partition 3 128 KiB, chardev (248:0)
tail: can't open '/dev/mmcblk0': No such file or directory
tail: no files
[ 5.471158] mmcblk0: p1 p2 p3 p4 p5 p6 p7
Implement a wait loop of up to 5s to wait for the device,
similar to what the kernel would do with rootwait.
Tested: Verified the error is not longer seen. Printing the count
value as debug, it took one sleep iteration to appear:
[ 4.396492] mmcblk0boot1: mmc0:0001 R1J56L partition 2 16.0 MiB
0
[ 4.403500] mmcblk0rpmb: mmc0:0001 R1J56L partition 3 128 KiB, chardev (248:0)
[ 4.416176] mmcblk0: p1 p2 p3 p4 p5 p6 p7
1
[ 6.159693] EXT4-fs (mmcblk0p4): mounted filesystem with ordered data mode. Opts: (null)
(From meta-phosphor rev: b7dccc1c380431f4cc96e0228fb9975d33df1f88)
Change-Id: I625a879882311285dbdeaa2ea271c379366f4b9b
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'meta-phosphor/recipes-phosphor/initrdscripts')
-rw-r--r-- | meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh | 16 |
1 files changed, 14 insertions, 2 deletions
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 index ec4b745db..d41ddf713 100644 --- a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh +++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh @@ -17,11 +17,23 @@ 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 /dev/mmcblk0 | hexdump -C -n 8 | grep "EFI PART") +magic=$(tail -c 512 "${mmcdev}" | hexdump -C -n 8 | grep "EFI PART") if test -z "${magic}"; then - sgdisk -e /dev/mmcblk0 + sgdisk -e "${mmcdev}" partprobe fi |