diff options
author | Anton Gerasimov <anton@advancedtelematic.com> | 2016-11-02 12:05:44 +0100 |
---|---|---|
committer | Anton Gerasimov <anton@advancedtelematic.com> | 2016-11-02 12:05:44 +0100 |
commit | 14ccbd8deca55fc611a502dc8ee817acd621d1f2 (patch) | |
tree | 10c8ef61998aa0c33df4b3da1fb622771eacf05c /classes | |
parent | a212922c56f6e7b13dcbbc83270d2444cde4d8f2 (diff) | |
download | meta-updater-14ccbd8deca55fc611a502dc8ee817acd621d1f2.tar.gz |
OTA-enabled live image for Porter board
Bug-AGL: SPEC-307
Change-Id: I74ddc2622048a50243b82fbf023aa05c33322af4
Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
Diffstat (limited to 'classes')
-rw-r--r-- | classes/sdcard_image-porter-ota.bbclass | 75 | ||||
-rw-r--r-- | classes/sdcard_image-rpi-ota.bbclass | 2 |
2 files changed, 76 insertions, 1 deletions
diff --git a/classes/sdcard_image-porter-ota.bbclass b/classes/sdcard_image-porter-ota.bbclass new file mode 100644 index 0000000..1b1de79 --- /dev/null +++ b/classes/sdcard_image-porter-ota.bbclass | |||
@@ -0,0 +1,75 @@ | |||
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_porter-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}" | ||
14 | IMAGE_DEPENDS_porter-sdimg-ota = " \ | ||
15 | parted-native \ | ||
16 | mtools-native \ | ||
17 | dosfstools-native \ | ||
18 | porter-bootfiles \ | ||
19 | " | ||
20 | |||
21 | SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.porter-sdimg-ota" | ||
22 | |||
23 | IMAGE_CMD_porter-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}/porter-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 | |||
diff --git a/classes/sdcard_image-rpi-ota.bbclass b/classes/sdcard_image-rpi-ota.bbclass index 12c1f40..2fa03c4 100644 --- a/classes/sdcard_image-rpi-ota.bbclass +++ b/classes/sdcard_image-rpi-ota.bbclass | |||
@@ -79,7 +79,7 @@ IMAGE_CMD_rpi-sdimg-ota[vardepsexclude] += "DATETIME" | |||
79 | IMAGE_CMD_rpi-sdimg-ota () { | 79 | IMAGE_CMD_rpi-sdimg-ota () { |
80 | 80 | ||
81 | # Align partitions | 81 | # Align partitions |
82 | OTAROOT_SIZE=`du -Lb ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE} | cut -f1` | 82 | OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1` |
83 | OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) | 83 | OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) |
84 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) | 84 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) |
85 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) | 85 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) |