diff options
author | Gatis Paeglis <gatis.paeglis@theqtcompany.com> | 2016-02-21 10:37:05 +0100 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@theqtcompany.com> | 2016-02-23 11:18:52 +0000 |
commit | 769ae5571a5501cbe9c3b12c560a3e6916bff4ca (patch) | |
tree | 33c5254310011553b5cbaa2d0303920ab0df6da1 /recipes | |
parent | f6af3a3551f3cb6c90aa05d90941c6140a674279 (diff) | |
download | meta-boot2qt-769ae5571a5501cbe9c3b12c560a3e6916bff4ca.tar.gz |
NUC: Use custom image layout
This patch adds a new image class 'image_dd', by default
it has an empty boot partition. image_dd_efi extends this
class to support Intel NUC board. The layout of a generated
image is a prerequisite for OSTree integarion.
Image generated by 'hddimg' produces rootfs.img (ext3
filesystem file) and then "live" boots it from initramfs
by mounting rootfs.img via loop device. For OTA integration
we need to access contents of rootfs.img already from
boot loader.
The custom 'image_nuc_efi' layout allow for fully atomic
updates on EFI based system, by keeping GRUB-EFI binary
on a dedicated EFI system partition (ESP). OSTree currently
is not fully atomic on EFI systems, but with this setup
we use GRUB-BIOS code path in OSTree, which is atomic.
After EFI firmware has loaded the GRUB-EFI binary, everything
else is done on rootfs parition.
One limitation from the above scenario is that you would
need to update /EFI/BOOT/bootx64.efi (GRUB-EFI) binary
manually. Not sure how common it is to update a boot loader
binary on a deployed system, but its not impossible.
Change-Id: Ibf2840aecd548000372131c4ded5cffa11ff1b0f
Reviewed-by: Teemu Holappa <teemu.holappa@theqtcompany.com>
Diffstat (limited to 'recipes')
-rw-r--r-- | recipes/initramfs-basic/files/init.sh | 102 | ||||
-rw-r--r-- | recipes/initramfs-basic/init-basic.bb | 34 | ||||
-rw-r--r-- | recipes/initramfs-basic/initramfs-basic.bb | 40 |
3 files changed, 176 insertions, 0 deletions
diff --git a/recipes/initramfs-basic/files/init.sh b/recipes/initramfs-basic/files/init.sh new file mode 100644 index 0000000..3db235b --- /dev/null +++ b/recipes/initramfs-basic/files/init.sh | |||
@@ -0,0 +1,102 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
4 | ROOT_MOUNT="/sysroot/" | ||
5 | ROOT_DEVICE="" | ||
6 | |||
7 | early_setup() { | ||
8 | |||
9 | mkdir -p /proc | ||
10 | mkdir -p /sys | ||
11 | mount -t proc proc /proc | ||
12 | mount -t sysfs sysfs /sys | ||
13 | mount -t devtmpfs none /dev | ||
14 | |||
15 | mkdir -p /run | ||
16 | mkdir -p /var/run | ||
17 | } | ||
18 | |||
19 | read_args() { | ||
20 | |||
21 | for arg in $(cat /proc/cmdline); do | ||
22 | value=$(echo ${arg} | cut -s -f2- -d '=') | ||
23 | case $arg in | ||
24 | root=*) | ||
25 | root=$value | ||
26 | ;; | ||
27 | debugshell*) | ||
28 | if [ -z "$value" ]; then | ||
29 | shelltimeout=30 | ||
30 | else | ||
31 | shelltimeout=$value | ||
32 | fi | ||
33 | ;; | ||
34 | esac | ||
35 | done | ||
36 | |||
37 | if [ -z "$root" ] ; then | ||
38 | debug_shell "No root= specified via kernel command line." | ||
39 | else | ||
40 | case $root in | ||
41 | LABEL=*) | ||
42 | label=${root#LABEL=} | ||
43 | ;; | ||
44 | *) | ||
45 | debug_shell "This init script only supports root=LABEL=* for specifying root file system, but root=$root was provided." | ||
46 | ;; | ||
47 | esac | ||
48 | fi | ||
49 | } | ||
50 | |||
51 | mount_rootfs() { | ||
52 | |||
53 | mkdir -p $ROOT_MOUNT | ||
54 | mount $ROOT_DEVICE $ROOT_MOUNT | ||
55 | mount -n --move /proc $ROOT_MOUNT/proc | ||
56 | mount -n --move /sys $ROOT_MOUNT/sys | ||
57 | mount -n --move /dev $ROOT_MOUNT/dev | ||
58 | |||
59 | exec switch_root $ROOT_MOUNT /sbin/init || debug_shell "Couldn't switch_root." | ||
60 | } | ||
61 | |||
62 | switch_real_root() { | ||
63 | |||
64 | echo "Searching for media..." | ||
65 | C=0 | ||
66 | while true | ||
67 | do | ||
68 | |||
69 | rootfs=$(findfs LABEL=$label) | ||
70 | if [ -n "$rootfs" ] ; then | ||
71 | ROOT_DEVICE=$rootfs | ||
72 | mount_rootfs | ||
73 | fi | ||
74 | |||
75 | # don't wait for more than $shelltimeout seconds, if it's set | ||
76 | if [ -n "$shelltimeout" ]; then | ||
77 | echo -n " " $(( $shelltimeout - $C )) | ||
78 | if [ $C -ge $shelltimeout ]; then | ||
79 | debug_shell "Cannot find root file system." | ||
80 | fi | ||
81 | C=$(( C + 1 )) | ||
82 | fi | ||
83 | |||
84 | sleep 1 | ||
85 | done | ||
86 | } | ||
87 | |||
88 | debug_shell() { | ||
89 | |||
90 | echo ${1} | ||
91 | echo "Dropping to a shell." | ||
92 | exec sh | ||
93 | } | ||
94 | |||
95 | main() { | ||
96 | |||
97 | early_setup | ||
98 | read_args | ||
99 | switch_real_root | ||
100 | } | ||
101 | |||
102 | main | ||
diff --git a/recipes/initramfs-basic/init-basic.bb b/recipes/initramfs-basic/init-basic.bb new file mode 100644 index 0000000..674e683 --- /dev/null +++ b/recipes/initramfs-basic/init-basic.bb | |||
@@ -0,0 +1,34 @@ | |||
1 | ############################################################################## | ||
2 | ## | ||
3 | ## Copyright (C) 2016 The Qt Company Ltd. | ||
4 | ## Contact: http://www.qt.io/licensing/ | ||
5 | ## | ||
6 | ## This file is part of the Boot to Qt meta layer. | ||
7 | ## | ||
8 | ## $QT_BEGIN_LICENSE:COMM$ | ||
9 | ## | ||
10 | ## Commercial License Usage | ||
11 | ## Licensees holding valid commercial Qt licenses may use this file in | ||
12 | ## accordance with the commercial license agreement provided with the | ||
13 | ## Software or, alternatively, in accordance with the terms contained in | ||
14 | ## a written agreement between you and The Qt Company. For licensing terms | ||
15 | ## and conditions see http://www.qt.io/terms-conditions. For further | ||
16 | ## information use the contact form at http://www.qt.io/contact-us. | ||
17 | ## | ||
18 | ## $QT_END_LICENSE$ | ||
19 | ## | ||
20 | ############################################################################## | ||
21 | |||
22 | SUMMARY = "Simple init script that mounts root filesystem by label." | ||
23 | LICENSE = "CLOSED" | ||
24 | SRC_URI = "file://init.sh" | ||
25 | |||
26 | S = "${WORKDIR}" | ||
27 | |||
28 | do_install () { | ||
29 | install -m 0755 ${WORKDIR}/init.sh ${D}/init | ||
30 | } | ||
31 | |||
32 | inherit allarch | ||
33 | |||
34 | FILES_${PN} += "/init" | ||
diff --git a/recipes/initramfs-basic/initramfs-basic.bb b/recipes/initramfs-basic/initramfs-basic.bb new file mode 100644 index 0000000..4bef9c8 --- /dev/null +++ b/recipes/initramfs-basic/initramfs-basic.bb | |||
@@ -0,0 +1,40 @@ | |||
1 | ############################################################################## | ||
2 | ## | ||
3 | ## Copyright (C) 2016 The Qt Company Ltd. | ||
4 | ## Contact: http://www.qt.io/licensing/ | ||
5 | ## | ||
6 | ## This file is part of the Boot to Qt meta layer. | ||
7 | ## | ||
8 | ## $QT_BEGIN_LICENSE:COMM$ | ||
9 | ## | ||
10 | ## Commercial License Usage | ||
11 | ## Licensees holding valid commercial Qt licenses may use this file in | ||
12 | ## accordance with the commercial license agreement provided with the | ||
13 | ## Software or, alternatively, in accordance with the terms contained in | ||
14 | ## a written agreement between you and The Qt Company. For licensing terms | ||
15 | ## and conditions see http://www.qt.io/terms-conditions. For further | ||
16 | ## information use the contact form at http://www.qt.io/contact-us. | ||
17 | ## | ||
18 | ## $QT_END_LICENSE$ | ||
19 | ## | ||
20 | ############################################################################## | ||
21 | |||
22 | DESCRIPTION = "Basic initramfs image. Useful as a template for more advanced functionality." | ||
23 | LICENSE = "CLOSED" | ||
24 | |||
25 | # findfs from busybox fails to do its jobs, the full version from util-linux-findfs works fine | ||
26 | PACKAGE_INSTALL = "init-basic busybox util-linux-findfs ${ROOTFS_BOOTSTRAP_INSTALL}" | ||
27 | |||
28 | # Do not pollute the initramfs image with rootfs features | ||
29 | IMAGE_FEATURES = "" | ||
30 | |||
31 | export IMAGE_BASENAME = "initramfs-basic" | ||
32 | IMAGE_LINGUAS = "" | ||
33 | |||
34 | IMAGE_FSTYPES = "cpio.gz" | ||
35 | inherit core-image | ||
36 | |||
37 | IMAGE_ROOTFS_SIZE = "8192" | ||
38 | |||
39 | BAD_RECOMMENDATIONS += "busybox-syslog" | ||
40 | |||