summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@theqtcompany.com>2016-02-21 10:37:05 +0100
committerGatis Paeglis <gatis.paeglis@theqtcompany.com>2016-02-23 11:18:52 +0000
commit769ae5571a5501cbe9c3b12c560a3e6916bff4ca (patch)
tree33c5254310011553b5cbaa2d0303920ab0df6da1 /classes
parentf6af3a3551f3cb6c90aa05d90941c6140a674279 (diff)
downloadmeta-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 'classes')
-rw-r--r--classes/image_dd.bbclass78
1 files changed, 78 insertions, 0 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