diff options
author | Jan-Simon Möller <jsmoeller@linuxfoundation.org> | 2016-11-12 10:54:58 +0100 |
---|---|---|
committer | Jan-Simon Möller <jsmoeller@linuxfoundation.org> | 2016-11-12 10:54:58 +0100 |
commit | 5d256428b1683ed3952d5aa554f96eb2f5c851ae (patch) | |
tree | b008edf6e0a196162638219c0ee38e952f84da8d | |
parent | 72df99753d8c944d706a6f863b446476a689f348 (diff) | |
download | meta-updater-5d256428b1683ed3952d5aa554f96eb2f5c851ae.tar.gz |
Add ota draft for ota image
Change-Id: I42debe5e710d9b1fc90f68a5d49e7fbb3e709cf4
Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
-rw-r--r-- | classes/sdcard_image-dra7xx-evm-ota.bbclass | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/classes/sdcard_image-dra7xx-evm-ota.bbclass b/classes/sdcard_image-dra7xx-evm-ota.bbclass new file mode 100644 index 0000000..f023649 --- /dev/null +++ b/classes/sdcard_image-dra7xx-evm-ota.bbclass | |||
@@ -0,0 +1,72 @@ | |||
1 | inherit image_types | ||
2 | |||
3 | # Boot partition volume id | ||
4 | BOOTDD_VOLUME_ID ?= "${MACHINE}" | ||
5 | |||
6 | # Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT) | ||
7 | BOOT_SPACE ?= "4096" | ||
8 | |||
9 | IMAGE_ROOTFS_ALIGNMENT = "4096" | ||
10 | SDIMG_OTA_ROOTFS_TYPE ?= "otaimg" | ||
11 | SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}" | ||
12 | |||
13 | IMAGE_TYPEDEP_dra7xx-evm-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}" | ||
14 | IMAGE_DEPENDS_dra7xx-evm-sdimg-ota = " \ | ||
15 | parted-native \ | ||
16 | mtools-native \ | ||
17 | dosfstools-native \ | ||
18 | " | ||
19 | |||
20 | SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.dra7xx-evm-sdimg-ota" | ||
21 | |||
22 | IMAGE_CMD_dra7xx-evm-sdimg-ota () { | ||
23 | OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1` | ||
24 | OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) | ||
25 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) | ||
26 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) | ||
27 | SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE) | ||
28 | |||
29 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB" | ||
30 | |||
31 | # Initialize sdcard image file | ||
32 | dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE} | ||
33 | |||
34 | # Create partition table | ||
35 | parted -s ${SDIMG_OTA} mklabel msdos | ||
36 | # Create boot partition and mark it as bootable | ||
37 | parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) | ||
38 | parted -s ${SDIMG_OTA} set 1 boot on | ||
39 | # Create rootfs partition to the end of disk | ||
40 | parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s | ||
41 | parted ${SDIMG_OTA} print | ||
42 | |||
43 | # Create a vfat image with boot files | ||
44 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') | ||
45 | rm -f ${WORKDIR}/boot.img | ||
46 | mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS | ||
47 | sync | ||
48 | |||
49 | sync | ||
50 | #dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync | ||
51 | |||
52 | if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz" | ||
53 | then | ||
54 | xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync | ||
55 | else | ||
56 | dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync | ||
57 | fi | ||
58 | |||
59 | # Optionally apply compression | ||
60 | case "${SDIMG_OTA_COMPRESSION}" in | ||
61 | "gzip") | ||
62 | gzip -k9 "${SDIMG_OTA}" | ||
63 | ;; | ||
64 | "bzip2") | ||
65 | bzip2 -k9 "${SDIMG_OTA}" | ||
66 | ;; | ||
67 | "xz") | ||
68 | xz -k "${SDIMG_OTA}" | ||
69 | ;; | ||
70 | esac | ||
71 | } | ||
72 | |||