summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--classes/sdcard_image-rpi-ota.bbclass190
-rw-r--r--classes/sota_am335x-evm-wifi.bbclass2
-rw-r--r--classes/sota_m3ulcb.bbclass1
-rw-r--r--classes/sota_porter.bbclass1
-rw-r--r--classes/sota_raspberrypi.bbclass8
-rw-r--r--recipes-core/images/initramfs-ostree-image.bb1
-rw-r--r--scripts/lib/wic/plugins/source/otaimage.py32
7 files changed, 13 insertions, 222 deletions
diff --git a/classes/sdcard_image-rpi-ota.bbclass b/classes/sdcard_image-rpi-ota.bbclass
deleted file mode 100644
index 9c859fe..0000000
--- a/classes/sdcard_image-rpi-ota.bbclass
+++ /dev/null
@@ -1,190 +0,0 @@
1inherit image_types
2inherit linux-raspberrypi-base
3
4#
5# Create an image that can by written onto a SD card using dd.
6#
7# The disk layout used is:
8#
9# 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved for other data
10# IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - bootloader and kernel
11# BOOT_SPACE -> SDIMG_OTA_SIZE - rootfs
12#
13
14# Default Free space = 1.3x
15# Use IMAGE_OVERHEAD_FACTOR to add more space
16# <--------->
17# 4MiB 40MiB SDIMG_OTA_ROOTFS
18# <-----------------------> <----------> <---------------------->
19# ------------------------ ------------ ------------------------
20# | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | OTAROOT_SIZE |
21# ------------------------ ------------ ------------------------
22# ^ ^ ^ ^
23# | | | |
24# 0 4MiB 4MiB + 40MiB 4MiB + 40Mib + SDIMG_OTA_ROOTFS
25
26# This image depends on the rootfs image
27IMAGE_TYPEDEP_rpi-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}"
28
29# Set kernel and boot loader
30IMAGE_BOOTLOADER ?= "bcm2835-bootfiles"
31
32# Set initramfs extension
33KERNEL_INITRAMFS ?= ""
34
35# Kernel image name
36SDIMG_OTA_KERNELIMAGE_raspberrypi ?= "kernel.img"
37SDIMG_OTA_KERNELIMAGE_raspberrypi2 ?= "kernel7.img"
38SDIMG_OTA_KERNELIMAGE_raspberrypi3 ?= "kernel7.img"
39
40# Boot partition volume id
41BOOTDD_VOLUME_ID ?= "${MACHINE}"
42
43# Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT)
44BOOT_SPACE ?= "40960"
45
46# Set alignment to 4MB [in KiB]
47IMAGE_ROOTFS_ALIGNMENT = "4096"
48
49# Use an uncompressed ext3 by default as rootfs
50SDIMG_OTA_ROOTFS_TYPE ?= "otaimg"
51SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}"
52
53IMAGE_DEPENDS_rpi-sdimg-ota = " \
54 parted-native \
55 mtools-native \
56 dosfstools-native \
57 virtual/kernel:do_deploy \
58 ${IMAGE_BOOTLOADER} \
59 u-boot \
60 "
61IMAGE_TYPEDEP_rpi-sdimg-ota = "otaimg"
62
63# SD card image name
64SDIMG_OTA = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.rpi-sdimg-ota"
65
66# Compression method to apply to SDIMG_OTA after it has been created. Supported
67# compression formats are "gzip", "bzip2" or "xz". The original .rpi-sdimg-ota file
68# is kept and a new compressed file is created if one of these compression
69# formats is chosen. If SDIMG_OTA_COMPRESSION is set to any other value it is
70# silently ignored.
71#SDIMG_OTA_COMPRESSION ?= ""
72
73# Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS.
74FATPAYLOAD ?= ""
75
76IMAGE_CMD_rpi-sdimg-ota () {
77
78 # Align partitions
79 OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1`
80 OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1)
81 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
82 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
83 SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE)
84
85 echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB"
86
87 # Check if we are building with device tree support
88 DTS="${@get_dts(d, None)}"
89
90 # Initialize sdcard image file
91 dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE}
92
93 # Create partition table
94 parted -s ${SDIMG_OTA} mklabel msdos
95 # Create boot partition and mark it as bootable
96 parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT})
97 parted -s ${SDIMG_OTA} set 1 boot on
98 # Create rootfs partition to the end of disk
99 parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s
100 parted ${SDIMG_OTA} print
101
102 # Create a vfat image with boot files
103 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
104 rm -f ${WORKDIR}/boot.img
105 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
106 sync
107
108 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/
109
110 if test -n "${DTS}"; then
111 # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder
112 DT_OVERLAYS="${@split_overlays(d, 0)}"
113 DT_ROOT="${@split_overlays(d, 1)}"
114
115 # Copy board device trees to root folder
116 for DTB in ${DT_ROOT}; do
117 DTB_BASE_NAME=`basename ${DTB} .dtb`
118
119 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb
120 done
121
122 # Copy device tree overlays to dedicated folder
123 mmd -i ${WORKDIR}/boot.img overlays
124 for DTB in ${DT_OVERLAYS}; do
125 DTB_EXT=${DTB##*.}
126 DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
127
128 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.${DTB_EXT} ::overlays/${DTB_BASE_NAME}.${DTB_EXT}
129 done
130 fi
131
132 case "${KERNEL_IMAGETYPE}" in
133 "uImage")
134 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_OTA_KERNELIMAGE}
135 ;;
136 *)
137 bbfatal "Kernel uImage is required for OTA image. Please set KERNEL_IMAGETYPE to \"uImage\""
138 ;;
139 esac
140
141 if [ -n ${FATPAYLOAD} ] ; then
142 echo "Copying payload into VFAT"
143 for entry in ${FATPAYLOAD} ; do
144 # add the || true to stop aborting on vfat issues like not supporting .~lock files
145 mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true
146 done
147 fi
148
149 # Add stamp file
150 echo "${IMAGE_NAME}" > ${WORKDIR}/image-version-info
151 mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}//image-version-info ::
152
153 # Burn Partitions
154 sync
155 dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
156 # If SDIMG_OTA_ROOTFS_TYPE is a .xz file use xzcat
157 if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz"
158 then
159 xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
160 else
161 dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
162 fi
163
164 # Optionally apply compression
165 case "${SDIMG_OTA_COMPRESSION}" in
166 "gzip")
167 gzip -k9 "${SDIMG_OTA}"
168 ;;
169 "bzip2")
170 bzip2 -k9 "${SDIMG_OTA}"
171 ;;
172 "xz")
173 xz -k "${SDIMG_OTA}"
174 ;;
175 esac
176}
177
178ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; "
179
180rpi_generate_sysctl_config() {
181 # systemd sysctl config
182 test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \
183 echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf
184
185 # sysv sysctl config
186 IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf"
187 test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \
188 sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF}
189 echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF}
190}
diff --git a/classes/sota_am335x-evm-wifi.bbclass b/classes/sota_am335x-evm-wifi.bbclass
index 821e8fb..adefb47 100644
--- a/classes/sota_am335x-evm-wifi.bbclass
+++ b/classes/sota_am335x-evm-wifi.bbclass
@@ -1,5 +1,3 @@
1IMAGE_CLASSES += "image_types_uboot"
2
3KERNEL_IMAGETYPE_sota = "uImage" 1KERNEL_IMAGETYPE_sota = "uImage"
4 2
5OSTREE_BOOTLOADER ?= "u-boot" 3OSTREE_BOOTLOADER ?= "u-boot"
diff --git a/classes/sota_m3ulcb.bbclass b/classes/sota_m3ulcb.bbclass
index 21d04ba..6b63af4 100644
--- a/classes/sota_m3ulcb.bbclass
+++ b/classes/sota_m3ulcb.bbclass
@@ -2,7 +2,6 @@
2OSTREE_KERNEL = "Image" 2OSTREE_KERNEL = "Image"
3 3
4EXTRA_IMAGEDEPENDS_append_sota = " m3ulcb-ota-bootfiles" 4EXTRA_IMAGEDEPENDS_append_sota = " m3ulcb-ota-bootfiles"
5IMAGE_CLASSES_append_sota = " image_types_uboot "
6IMAGE_BOOT_FILES_sota += "m3ulcb-ota-bootfiles/*" 5IMAGE_BOOT_FILES_sota += "m3ulcb-ota-bootfiles/*"
7 6
8OSTREE_BOOTLOADER ?= "u-boot" 7OSTREE_BOOTLOADER ?= "u-boot"
diff --git a/classes/sota_porter.bbclass b/classes/sota_porter.bbclass
index a8f5ba1..75ae579 100644
--- a/classes/sota_porter.bbclass
+++ b/classes/sota_porter.bbclass
@@ -2,7 +2,6 @@
2OSTREE_KERNEL = "uImage+dtb" 2OSTREE_KERNEL = "uImage+dtb"
3 3
4EXTRA_IMAGEDEPENDS_append_sota = " porter-bootfiles" 4EXTRA_IMAGEDEPENDS_append_sota = " porter-bootfiles"
5IMAGE_CLASSES_append_sota = " image_types_uboot "
6IMAGE_BOOT_FILES_sota += "porter-bootfiles/*" 5IMAGE_BOOT_FILES_sota += "porter-bootfiles/*"
7 6
8OSTREE_BOOTLOADER ?= "u-boot" 7OSTREE_BOOTLOADER ?= "u-boot"
diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass
index cc6b666..51d07b2 100644
--- a/classes/sota_raspberrypi.bbclass
+++ b/classes/sota_raspberrypi.bbclass
@@ -1,11 +1,9 @@
1IMAGE_CLASSES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'image_types_uboot sdcard_image-rpi-ota', '', d)}"
2IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'rpi-sdimg-ota.xz', 'rpi-sdimg.xz', d)}"
3
4IMAGE_FSTYPES_remove = "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'wic rpi-sdimg rpi-sdimg.xz', '', d)}"
5
6KERNEL_IMAGETYPE_sota = "uImage" 1KERNEL_IMAGETYPE_sota = "uImage"
7PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" 2PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot"
8UBOOT_MACHINE_raspberrypi2_sota ?= "rpi_2_defconfig" 3UBOOT_MACHINE_raspberrypi2_sota ?= "rpi_2_defconfig"
9UBOOT_MACHINE_raspberrypi3_sota ?= "rpi_3_32b_defconfig" 4UBOOT_MACHINE_raspberrypi3_sota ?= "rpi_3_32b_defconfig"
10 5
11OSTREE_BOOTLOADER ?= "u-boot" 6OSTREE_BOOTLOADER ?= "u-boot"
7
8# OSTree puts its own boot.scr to bcm2835-bootfiles
9IMAGE_BOOT_FILES_remove_sota += "boot.scr"
diff --git a/recipes-core/images/initramfs-ostree-image.bb b/recipes-core/images/initramfs-ostree-image.bb
index 4870579..4ab9da8 100644
--- a/recipes-core/images/initramfs-ostree-image.bb
+++ b/recipes-core/images/initramfs-ostree-image.bb
@@ -15,7 +15,6 @@ LICENSE = "MIT"
15 15
16IMAGE_FSTYPES = "ext4.gz" 16IMAGE_FSTYPES = "ext4.gz"
17IMAGE_FSTYPES_append_arm = " ext4.gz.u-boot" 17IMAGE_FSTYPES_append_arm = " ext4.gz.u-boot"
18IMAGE_CLASSES_append_arm = " image_types_uboot"
19 18
20inherit core-image 19inherit core-image
21 20
diff --git a/scripts/lib/wic/plugins/source/otaimage.py b/scripts/lib/wic/plugins/source/otaimage.py
index eef0bb4..26cfb10 100644
--- a/scripts/lib/wic/plugins/source/otaimage.py
+++ b/scripts/lib/wic/plugins/source/otaimage.py
@@ -19,10 +19,12 @@ import logging
19import os 19import os
20import sys 20import sys
21 21
22from wic.pluginbase import SourcePlugin 22from wic.plugins.source.rawcopy import RawCopyPlugin
23from wic.utils.misc import get_bitbake_var 23from wic.utils.misc import get_bitbake_var
24 24
25class OTAImagePlugin(SourcePlugin): 25logger = logging.getLogger('wic')
26
27class OTAImagePlugin(RawCopyPlugin):
26 """ 28 """
27 Add an already existing filesystem image to the partition layout. 29 Add an already existing filesystem image to the partition layout.
28 """ 30 """
@@ -30,25 +32,6 @@ class OTAImagePlugin(SourcePlugin):
30 name = 'otaimage' 32 name = 'otaimage'
31 33
32 @classmethod 34 @classmethod
33 def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir,
34 bootimg_dir, kernel_dir, native_sysroot):
35 """
36 Called after all partitions have been prepared and assembled into a
37 disk image. Do nothing.
38 """
39 pass
40
41 @classmethod
42 def do_configure_partition(cls, part, source_params, cr, cr_workdir,
43 oe_builddir, bootimg_dir, kernel_dir,
44 native_sysroot):
45 """
46 Called before do_prepare_partition(). Possibly prepare
47 configuration files of some sort.
48 """
49 pass
50
51 @classmethod
52 def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 35 def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
53 oe_builddir, bootimg_dir, kernel_dir, 36 oe_builddir, bootimg_dir, kernel_dir,
54 rootfs_dir, native_sysroot): 37 rootfs_dir, native_sysroot):
@@ -65,5 +48,10 @@ class OTAImagePlugin(SourcePlugin):
65 src = bootimg_dir + "/" + get_bitbake_var("IMAGE_LINK_NAME") + ".otaimg" 48 src = bootimg_dir + "/" + get_bitbake_var("IMAGE_LINK_NAME") + ".otaimg"
66 49
67 logger.debug('Preparing partition using image %s' % (src)) 50 logger.debug('Preparing partition using image %s' % (src))
68 part.prepare_rootfs_from_fs_image(cr_workdir, src, "") 51 source_params['file'] = src
52
53 super(OTAImagePlugin, cls).do_prepare_partition(part, source_params,
54 cr, cr_workdir, oe_builddir,
55 bootimg_dir, kernel_dir,
56 rootfs_dir, native_sysroot)
69 57