summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initrdscripts
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-07-01 15:53:51 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-08 09:57:26 +0100
commitee6a6c3461694ce09789bf4d852cea2e22fc95e4 (patch)
treefe1d939900dac7954f4828fcbecd1da210d9b8d3 /meta/recipes-core/initrdscripts
parente34eb01c0f0cf5e893d919eb74111115f57870f7 (diff)
downloadpoky-ee6a6c3461694ce09789bf4d852cea2e22fc95e4.tar.gz
initramfs-framework: add retry loop for slow boot devices (like USB)
On some hardware platforms (Gigabyte, qemu), detection of USB devices by the kernel is slow enough such that it happens only after the first attempt to mount the rootfs. We need to keep trying for a while (default: 5s seconds, controlled by roottimeout=<seconds>) and sleep between each attempt (default: one second, rootdelay=<seconds>). This change intentionally splits finding the rootfs (in the new "rootfs") and switching to it ("finish"). That is needed to keep udev running while waiting for the rootfs, because it shuts down before "finish" starts. It is also the direction that was discussed on the OE mailing list for future changes to initramfs-framework (like supporting a "live CD" module, which would replace or further augment mounting of the rootfs). (From OE-Core rev: 2a50bb9ee8838e3d026c82dc09aaccb880a264f4) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/initrdscripts')
-rwxr-xr-xmeta/recipes-core/initrdscripts/initramfs-framework/finish33
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-framework/rootfs57
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb4
3 files changed, 60 insertions, 34 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index d09bbb8bed..717383ebac 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -8,39 +8,6 @@ finish_enabled() {
8 8
9finish_run() { 9finish_run() {
10 if [ -n "$ROOTFS_DIR" ]; then 10 if [ -n "$ROOTFS_DIR" ]; then
11 if [ -n "$bootparam_rootdelay" ]; then
12 debug "Sleeping for $rootdelay second(s) to wait root to settle..."
13 sleep $bootparam_rootdelay
14 fi
15
16 if [ -n "$bootparam_root" ]; then
17 debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..."
18
19 if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then
20 root_uuid=`echo $bootparam_root | cut -c6-`
21 bootparam_root="/dev/disk/by-uuid/$root_uuid"
22 fi
23
24 if [ -e "$bootparam_root" ]; then
25 flags=""
26 if [ -n "$bootparam_ro" ]; then
27 if [ -n "$bootparam_rootflags" ]; then
28 bootparam_rootflags="$bootparam_rootflags,"
29 fi
30 bootparam_rootflags="${bootparam_rootflags}ro"
31 fi
32 if [ -n "$bootparam_rootflags" ]; then
33 flags="$flags -o$bootparam_rootflags"
34 fi
35 if [ -n "$bootparam_rootfstype" ]; then
36 flags="$flags -t$bootparam_rootfstype"
37 fi
38 mount $flags $bootparam_root $ROOTFS_DIR
39 else
40 msg "root '$bootparam_root' doesn't exist."
41 fi
42 fi
43
44 if [ ! -d $ROOTFS_DIR/dev ]; then 11 if [ ! -d $ROOTFS_DIR/dev ]; then
45 fatal "ERROR: There's no '/dev' on rootfs." 12 fatal "ERROR: There's no '/dev' on rootfs."
46 fi 13 fi
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
new file mode 100644
index 0000000000..5790d8cb8b
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
@@ -0,0 +1,57 @@
1#!/bin/sh
2# Copyright (C) 2011 O.S. Systems Software LTDA.
3# Licensed on MIT
4
5rootfs_enabled() {
6 return 0
7}
8
9rootfs_run() {
10 if [ -z "$ROOTFS_DIR" ]; then
11 return
12 fi
13 C=0
14 delay=${bootparam_rootdelay:-1}
15 timeout=${bootparam_roottimeout:-5}
16 while [ ! -d $ROOTFS_DIR/dev ]; do
17 if [ $(( $C * $delay )) -gt $timeout ]; then
18 fatal "root '$bootparam_root' doesn't exist or does not contain a /dev."
19 fi
20
21 if [ -n "$bootparam_root" ]; then
22 debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..."
23
24 if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then
25 root_uuid=`echo $bootparam_root | cut -c6-`
26 bootparam_root="/dev/disk/by-uuid/$root_uuid"
27 fi
28
29 if [ -e "$bootparam_root" ]; then
30 flags=""
31 if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then
32 if [ -n "$bootparam_rootflags" ]; then
33 bootparam_rootflags="$bootparam_rootflags,"
34 fi
35 bootparam_rootflags="${bootparam_rootflags}ro"
36 fi
37 if [ -n "$bootparam_rootflags" ]; then
38 flags="$flags -o$bootparam_rootflags"
39 fi
40 if [ -n "$bootparam_rootfstype" ]; then
41 flags="$flags -t$bootparam_rootfstype"
42 fi
43 mount $flags $bootparam_root $ROOTFS_DIR
44 if [ -d $ROOTFS_DIR/dev ]; then
45 break
46 else
47 # It is unlikely to change, but keep trying anyway.
48 # Perhaps we pick a different device next time.
49 umount $ROOTFS_DIR
50 fi
51 fi
52 fi
53 debug "Sleeping for $delay second(s) to wait root to settle..."
54 sleep $delay
55 C=$(( $C + 1 ))
56 done
57}
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
index e5cf9cb4dd..89e153d348 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
@@ -8,6 +8,7 @@ PR = "r2"
8inherit allarch 8inherit allarch
9 9
10SRC_URI = "file://init \ 10SRC_URI = "file://init \
11 file://rootfs \
11 file://finish \ 12 file://finish \
12 file://mdev \ 13 file://mdev \
13 file://udev \ 14 file://udev \
@@ -21,6 +22,7 @@ do_install() {
21 22
22 # base 23 # base
23 install -m 0755 ${WORKDIR}/init ${D}/init 24 install -m 0755 ${WORKDIR}/init ${D}/init
25 install -m 0755 ${WORKDIR}/rootfs ${D}/init.d/90-rootfs
24 install -m 0755 ${WORKDIR}/finish ${D}/init.d/99-finish 26 install -m 0755 ${WORKDIR}/finish ${D}/init.d/99-finish
25 27
26 # mdev 28 # mdev
@@ -47,7 +49,7 @@ PACKAGES = "${PN}-base \
47 initramfs-module-e2fs \ 49 initramfs-module-e2fs \
48 initramfs-module-debug" 50 initramfs-module-debug"
49 51
50FILES_${PN}-base = "/init /init.d/99-finish /dev" 52FILES_${PN}-base = "/init /init.d/90-rootfs /init.d/99-finish /dev"
51 53
52SUMMARY_initramfs-module-mdev = "initramfs support for mdev" 54SUMMARY_initramfs-module-mdev = "initramfs support for mdev"
53RDEPENDS_initramfs-module-mdev = "${PN}-base busybox-mdev" 55RDEPENDS_initramfs-module-mdev = "${PN}-base busybox-mdev"