summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Gerasimov <anton@advancedtelematic.com>2016-12-28 17:38:59 +0100
committerAnton Gerasimov <anton@advancedtelematic.com>2016-12-28 17:38:59 +0100
commit72ddd7ad2563b3a2e99311d1969832c858733543 (patch)
tree0f8bb799e9fe970b2d0bcf85089f1ba5537b0599
parenta7ba4cb2893b5441038a39b98a760664440561da (diff)
downloadmeta-updater-72ddd7ad2563b3a2e99311d1969832c858733543.tar.gz
Add OTA SD image for Minnowboard
-rw-r--r--classes/sdcard_image-minnowboard-ota.bbclass78
-rw-r--r--classes/sdcard_image-porter-ota.bbclass3
-rw-r--r--classes/sdcard_image-rpi-ota.bbclass3
-rw-r--r--conf/distro/sota.conf.inc2
4 files changed, 86 insertions, 0 deletions
diff --git a/classes/sdcard_image-minnowboard-ota.bbclass b/classes/sdcard_image-minnowboard-ota.bbclass
new file mode 100644
index 0000000..c49b3cd
--- /dev/null
+++ b/classes/sdcard_image-minnowboard-ota.bbclass
@@ -0,0 +1,78 @@
1inherit image_types
2
3# Boot partition volume id
4BOOTDD_VOLUME_ID ?= "${MACHINE}"
5
6# Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT)
7BOOT_SPACE ?= "4096"
8
9IMAGE_ROOTFS_ALIGNMENT = "4096"
10SDIMG_OTA_ROOTFS_TYPE ?= "otaimg"
11SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}"
12
13IMAGE_TYPEDEP_minnowboard-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}"
14IMAGE_DEPENDS_minnowboard-sdimg-ota = " \
15 parted-native \
16 mtools-native \
17 dosfstools-native \
18 minnowboard-bootfiles \
19 "
20
21SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.minnowboard-sdimg-ota"
22
23IMAGE_CMD_minnowboard-sdimg-ota () {
24 OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1`
25 OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1)
26 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
27 BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
28 SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE)
29
30 echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB"
31
32 # Initialize sdcard image file
33 dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE}
34
35 # Create partition table
36 parted -s ${SDIMG_OTA} mklabel msdos
37 # Create boot partition and mark it as bootable
38 parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT})
39 parted -s ${SDIMG_OTA} set 1 boot on
40 # Create rootfs partition to the end of disk
41 parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s
42 parted ${SDIMG_OTA} print
43
44 # Create a vfat image with boot files
45 BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }')
46 rm -f ${WORKDIR}/boot.img
47 mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
48 sync
49
50 mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/minnowboard-bootfiles/* ::/
51
52 sync
53 dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
54
55 if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz"
56 then
57 xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
58 else
59 dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
60 fi
61
62 # Optionally apply compression
63 case "${SDIMG_OTA_COMPRESSION}" in
64 "gzip")
65 gzip -k9 "${SDIMG_OTA}"
66 ;;
67 "bzip2")
68 bzip2 -k9 "${SDIMG_OTA}"
69 ;;
70 "xz")
71 xz -k "${SDIMG_OTA}"
72 ;;
73 esac
74
75 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.minnowboard-sdimg-ota
76 ln -s ${IMAGE_NAME}.minnowboard-sdimg-ota ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.minnowboard-sdimg-ota
77}
78
diff --git a/classes/sdcard_image-porter-ota.bbclass b/classes/sdcard_image-porter-ota.bbclass
index 1b1de79..5909b44 100644
--- a/classes/sdcard_image-porter-ota.bbclass
+++ b/classes/sdcard_image-porter-ota.bbclass
@@ -59,6 +59,9 @@ IMAGE_CMD_porter-sdimg-ota () {
59 dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync 59 dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
60 fi 60 fi
61 61
62 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.porter-sdimg-ota
63 ln -s ${IMAGE_NAME}.porter-sdimg-ota ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.porter-sdimg-ota
64
62 # Optionally apply compression 65 # Optionally apply compression
63 case "${SDIMG_OTA_COMPRESSION}" in 66 case "${SDIMG_OTA_COMPRESSION}" in
64 "gzip") 67 "gzip")
diff --git a/classes/sdcard_image-rpi-ota.bbclass b/classes/sdcard_image-rpi-ota.bbclass
index 2fa03c4..8fc2605 100644
--- a/classes/sdcard_image-rpi-ota.bbclass
+++ b/classes/sdcard_image-rpi-ota.bbclass
@@ -162,6 +162,9 @@ IMAGE_CMD_rpi-sdimg-ota () {
162 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 dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync
163 fi 163 fi
164 164
165 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rpi-sdimg-ota
166 ln -s ${IMAGE_NAME}.rpi-sdimg-ota ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rpi-sdimg-ota
167
165 # Optionally apply compression 168 # Optionally apply compression
166 case "${SDIMG_OTA_COMPRESSION}" in 169 case "${SDIMG_OTA_COMPRESSION}" in
167 "gzip") 170 "gzip")
diff --git a/conf/distro/sota.conf.inc b/conf/distro/sota.conf.inc
index d9b88c7..23e5a43 100644
--- a/conf/distro/sota.conf.inc
+++ b/conf/distro/sota.conf.inc
@@ -32,6 +32,8 @@ DISTRO_TYPE ?= "${@bb.utils.contains("IMAGE_FEATURES", "debug-tweaks", "debug",
32## Minnowboard 32## Minnowboard
33PREFERRED_PROVIDER_virtual/bootloader_intel-corei7-64 = "u-boot-ota" 33PREFERRED_PROVIDER_virtual/bootloader_intel-corei7-64 = "u-boot-ota"
34UBOOT_MACHINE_intel-corei7-64 = "minnowmax_defconfig" 34UBOOT_MACHINE_intel-corei7-64 = "minnowmax_defconfig"
35IMAGE_CLASSES_append_intel-corei7-64 = " sdcard_image-minnowboard-ota"
36IMAGE_FSTYPES += "${@'minnowboard-sdimg-ota' if d.getVar('MACHINE', True).startswith('intel-corei7-64') else ''}"
35 37
36## QEMU 38## QEMU
37PREFERRED_PROVIDER_virtual/bootloader_qemux86 = "u-boot-ota" 39PREFERRED_PROVIDER_virtual/bootloader_qemux86 = "u-boot-ota"