summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--classes/image_dd.bbclass78
-rw-r--r--conf/distro/include/nuc.conf6
-rw-r--r--meta-nuc-extras/classes/image_dd_efi.bbclass45
-rw-r--r--meta-nuc-extras/recipes/grub/grub-efi/grub.cfg10
-rw-r--r--meta-nuc-extras/recipes/grub/grub-efi_2.00.bbappend40
-rw-r--r--recipes/initramfs-basic/files/init.sh102
-rw-r--r--recipes/initramfs-basic/init-basic.bb34
-rw-r--r--recipes/initramfs-basic/initramfs-basic.bb40
8 files changed, 354 insertions, 1 deletions
diff --git a/classes/image_dd.bbclass b/classes/image_dd.bbclass
new file mode 100644
index 0000000..4d193b7
--- /dev/null
+++ b/classes/image_dd.bbclass
@@ -0,0 +1,78 @@
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# This class is based on meta-fsl-arm/classes/image_types_fsl.bbclass::generate_imx_sdcard()
23DESCRIPTION = "The base class for building images that can be deployed with GNU coreutils dd tool."
24inherit image_types
25
26IMAGE="${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.img"
27
28# Boot partition size [in KiB]
29BOOT_SPACE ?= "8192"
30
31# Set alignment to 4MB [in KiB]
32IMAGE_ROOTFS_ALIGNMENT = "4096"
33
34# Boot partition volume id
35BOOTDD_VOLUME_ID = "boot"
36
37IMAGE_TYPEDEP_dd = "ext3"
38IMAGE_DEPENDS_dd = "parted-native:do_populate_sysroot \
39 dosfstools-native:do_populate_sysroot \
40 mtools-native:do_populate_sysroot"
41
42image_dd_do_populate_boot() {
43}
44EXPORT_FUNCTIONS do_populate_boot
45
46IMAGE_CMD_dd() {
47
48 ROOTFS="${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
49
50 # Align boot partition and calculate total binary image size
51 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
52 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
53 IMAGE_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT})
54
55 # Initialize a sparse file
56 dd if=/dev/zero of=${IMAGE} bs=1 count=0 seek=$(expr 1024 \* ${IMAGE_SIZE})
57
58 # Create partition table
59 parted -s ${IMAGE} mklabel msdos
60 parted -s ${IMAGE} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED})
61 parted -s ${IMAGE} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE)
62 parted -s ${IMAGE} set 1 boot on
63 parted ${IMAGE} print
64
65 # Create boot partition image
66 BOOT_BLOCKS=$(LC_ALL=C parted -s ${IMAGE} unit b print \
67 | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 1024 }')
68 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
69 do_populate_boot
70
71 # Burn Partitions
72 dd if=${WORKDIR}/boot.img of=${IMAGE} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
73 dd if=${ROOTFS} of=${IMAGE} conv=notrunc seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
74
75 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.img
76 ln -s ${IMAGE_NAME}.rootfs.img ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.img
77}
78
diff --git a/conf/distro/include/nuc.conf b/conf/distro/include/nuc.conf
index fe04572..8a41388 100644
--- a/conf/distro/include/nuc.conf
+++ b/conf/distro/include/nuc.conf
@@ -25,13 +25,17 @@ DISTRO_FEATURES_DEFAULT += "wayland weston"
25 25
26DISTRO_FEATURES_remove = "usbgadget" 26DISTRO_FEATURES_remove = "usbgadget"
27 27
28IMAGE_FSTYPES += " hddimg" 28IMAGE_CLASSES += "image_dd_efi"
29IMAGE_FSTYPES += "ext3 dd"
30
31INITRAMFS_IMAGE = "initramfs-basic"
29 32
30SYSVINIT_ENABLED_GETTYS = "1" 33SYSVINIT_ENABLED_GETTYS = "1"
31 34
32MACHINE_EXTRA_INSTALL = "\ 35MACHINE_EXTRA_INSTALL = "\
33 wayland \ 36 wayland \
34 mesa-megadriver \ 37 mesa-megadriver \
38 grub-efi-config \
35 " 39 "
36 40
37MACHINE_EXTRA_INSTALL_SDK = " \ 41MACHINE_EXTRA_INSTALL_SDK = " \
diff --git a/meta-nuc-extras/classes/image_dd_efi.bbclass b/meta-nuc-extras/classes/image_dd_efi.bbclass
new file mode 100644
index 0000000..7bbff62
--- /dev/null
+++ b/meta-nuc-extras/classes/image_dd_efi.bbclass
@@ -0,0 +1,45 @@
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
22DESCRIPTION = "Extends image_dd class to boot via GRUB-EFI and initramfs."
23LICENSE = "CLOSED"
24
25inherit image_dd
26
27EXTRA_IMAGECMD_ext3 += "-L rootfs"
28IMAGE_DEPENDS_ext3 += "initramfs-basic:do_rootfs"
29
30IMAGE_CMD_ext3_prepend() {
31
32 # https://www.kernel.org/doc/Documentation/x86/early-microcode.txt
33 microcode="${@bb.utils.contains('MACHINE_FEATURES', 'intel-ucode', '${DEPLOY_DIR_IMAGE}/microcode.cpio ', '', d)}"
34 cat ${microcode} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.cpio.gz > ${IMAGE_ROOTFS}/boot/initramfs
35 chmod 0644 ${IMAGE_ROOTFS}/boot/initramfs
36}
37
38do_populate_boot() {
39
40 mkdir -p ${WORKDIR}/EFI/BOOT/
41 # Path where EFI firmware searches for EFI executable
42 cp ${DEPLOY_DIR_IMAGE}/bootx64.efi ${WORKDIR}/EFI/BOOT/
43 mcopy -s -i ${WORKDIR}/boot.img ${WORKDIR}/EFI ::/EFI
44}
45
diff --git a/meta-nuc-extras/recipes/grub/grub-efi/grub.cfg b/meta-nuc-extras/recipes/grub/grub-efi/grub.cfg
new file mode 100644
index 0000000..ca53537
--- /dev/null
+++ b/meta-nuc-extras/recipes/grub/grub-efi/grub.cfg
@@ -0,0 +1,10 @@
1# Created by meta-b2qt
2serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
3default=boot
4timeout=10
5
6menuentry 'boot' {
7 linux /boot/bzImage root=LABEL=rootfs
8 initrd /boot/initramfs
9}
10
diff --git a/meta-nuc-extras/recipes/grub/grub-efi_2.00.bbappend b/meta-nuc-extras/recipes/grub/grub-efi_2.00.bbappend
new file mode 100644
index 0000000..d002240
--- /dev/null
+++ b/meta-nuc-extras/recipes/grub/grub-efi_2.00.bbappend
@@ -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
22FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
23SRC_URI += "file://grub.cfg"
24
25do_deploy_prepend() {
26
27cat > ${WORKDIR}/cfg <<EOF
28search.file /boot/grub2/grub.cfg root
29set prefix=/boot/grub2
30EOF
31}
32
33do_install_append() {
34
35 install -d ${D}/boot/grub2/
36 install -m 644 ${WORKDIR}/grub.cfg ${D}/boot/grub2/
37}
38
39PACKAGES += "${PN}-config"
40FILES_${PN}-config = "/boot/grub2/"
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
3PATH=/sbin:/bin:/usr/sbin:/usr/bin
4ROOT_MOUNT="/sysroot/"
5ROOT_DEVICE=""
6
7early_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
19read_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
51mount_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
62switch_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
88debug_shell() {
89
90 echo ${1}
91 echo "Dropping to a shell."
92 exec sh
93}
94
95main() {
96
97 early_setup
98 read_args
99 switch_real_root
100}
101
102main
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
22SUMMARY = "Simple init script that mounts root filesystem by label."
23LICENSE = "CLOSED"
24SRC_URI = "file://init.sh"
25
26S = "${WORKDIR}"
27
28do_install () {
29 install -m 0755 ${WORKDIR}/init.sh ${D}/init
30}
31
32inherit allarch
33
34FILES_${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
22DESCRIPTION = "Basic initramfs image. Useful as a template for more advanced functionality."
23LICENSE = "CLOSED"
24
25# findfs from busybox fails to do its jobs, the full version from util-linux-findfs works fine
26PACKAGE_INSTALL = "init-basic busybox util-linux-findfs ${ROOTFS_BOOTSTRAP_INSTALL}"
27
28# Do not pollute the initramfs image with rootfs features
29IMAGE_FEATURES = ""
30
31export IMAGE_BASENAME = "initramfs-basic"
32IMAGE_LINGUAS = ""
33
34IMAGE_FSTYPES = "cpio.gz"
35inherit core-image
36
37IMAGE_ROOTFS_SIZE = "8192"
38
39BAD_RECOMMENDATIONS += "busybox-syslog"
40