From 769ae5571a5501cbe9c3b12c560a3e6916bff4ca Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Sun, 21 Feb 2016 10:37:05 +0100 Subject: 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 --- meta-nuc-extras/classes/image_dd_efi.bbclass | 45 ++++++++++++++++++++++ meta-nuc-extras/recipes/grub/grub-efi/grub.cfg | 10 +++++ .../recipes/grub/grub-efi_2.00.bbappend | 40 +++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 meta-nuc-extras/classes/image_dd_efi.bbclass create mode 100644 meta-nuc-extras/recipes/grub/grub-efi/grub.cfg create mode 100644 meta-nuc-extras/recipes/grub/grub-efi_2.00.bbappend (limited to 'meta-nuc-extras') 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 @@ +############################################################################## +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the Boot to Qt meta layer. +## +## $QT_BEGIN_LICENSE:COMM$ +## +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see http://www.qt.io/terms-conditions. For further +## information use the contact form at http://www.qt.io/contact-us. +## +## $QT_END_LICENSE$ +## +############################################################################## + +DESCRIPTION = "Extends image_dd class to boot via GRUB-EFI and initramfs." +LICENSE = "CLOSED" + +inherit image_dd + +EXTRA_IMAGECMD_ext3 += "-L rootfs" +IMAGE_DEPENDS_ext3 += "initramfs-basic:do_rootfs" + +IMAGE_CMD_ext3_prepend() { + + # https://www.kernel.org/doc/Documentation/x86/early-microcode.txt + microcode="${@bb.utils.contains('MACHINE_FEATURES', 'intel-ucode', '${DEPLOY_DIR_IMAGE}/microcode.cpio ', '', d)}" + cat ${microcode} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.cpio.gz > ${IMAGE_ROOTFS}/boot/initramfs + chmod 0644 ${IMAGE_ROOTFS}/boot/initramfs +} + +do_populate_boot() { + + mkdir -p ${WORKDIR}/EFI/BOOT/ + # Path where EFI firmware searches for EFI executable + cp ${DEPLOY_DIR_IMAGE}/bootx64.efi ${WORKDIR}/EFI/BOOT/ + mcopy -s -i ${WORKDIR}/boot.img ${WORKDIR}/EFI ::/EFI +} + 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 @@ +# Created by meta-b2qt +serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 +default=boot +timeout=10 + +menuentry 'boot' { + linux /boot/bzImage root=LABEL=rootfs + initrd /boot/initramfs +} + 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 @@ +############################################################################## +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the Boot to Qt meta layer. +## +## $QT_BEGIN_LICENSE:COMM$ +## +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see http://www.qt.io/terms-conditions. For further +## information use the contact form at http://www.qt.io/contact-us. +## +## $QT_END_LICENSE$ +## +############################################################################## + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +SRC_URI += "file://grub.cfg" + +do_deploy_prepend() { + +cat > ${WORKDIR}/cfg <