diff options
-rw-r--r-- | classes/image_type_tezi.bbclass | 188 |
1 files changed, 133 insertions, 55 deletions
diff --git a/classes/image_type_tezi.bbclass b/classes/image_type_tezi.bbclass index 5153423..9a5bcbe 100644 --- a/classes/image_type_tezi.bbclass +++ b/classes/image_type_tezi.bbclass @@ -2,21 +2,20 @@ inherit image_types IMAGE_DEPENDS_teziimg = "tezi-metadata:do_deploy" -python rootfs_tezi_json() { - if not bb.utils.contains("IMAGE_FSTYPES", "teziimg", True, False, d): - return - - import json, subprocess - from datetime import date - from collections import OrderedDict +def rootfs_get_size(d): + import subprocess - # Calculate size of rootfs... + # Calculate size of rootfs in kilobytes... output = subprocess.check_output(['du', '-ks', d.getVar('IMAGE_ROOTFS', True)]) - rootfssize_kb = int(output.split()[0]) + return int(output.split()[0]) +def rootfs_tezi_emmc(d): + import subprocess + from collections import OrderedDict deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) kernel = d.getVar('KERNEL_IMAGETYPE', True) + imagename = d.getVar('IMAGE_NAME', True) # Calculate size of bootfs... bootfiles = [ os.path.join(deploydir, kernel) ] @@ -28,6 +27,125 @@ python rootfs_tezi_json() { output = subprocess.check_output(args) bootfssize_kb = int(output.splitlines()[-1].split()[0]) + return [ + OrderedDict({ + "name": "mmcblk0", + "partitions": [ + { + "partition_size_nominal": 16, + "want_maximised": False, + "content": { + "label": "BOOT", + "filesystem_type": "FAT", + "mkfs_options": "", + "filename": imagename + ".bootfs.tar.xz", + "uncompressed_size": bootfssize_kb / 1024 + } + }, + { + "partition_size_nominal": 512, + "want_maximised": True, + "content": { + "label": "RFS", + "filesystem_type": "ext3", + "mkfs_options": "", + "filename": imagename + ".rootfs.tar.xz", + "uncompressed_size": rootfs_get_size(d) / 1024 + } + } + ] + }), + OrderedDict({ + "name": "mmcblk0boot0", + "content": { + "filesystem_type": "raw", + "rawfiles": [ + { + "filename": d.getVar('SPL_BINARY', True), + "dd_options": "seek=2" + }, + { + "filename": d.getVar('UBOOT_BINARY', True), + "dd_options": "seek=138" + } + ] + } + })] + + +def rootfs_tezi_rawnand(d): + from collections import OrderedDict + imagename = d.getVar('IMAGE_NAME', True) + + # Use device tree mapping to create product id <-> device tree relationship + dtmapping = d.getVarFlags('TORADEX_PRODUCT_IDS') + dtfiles = [] + for f, v in dtmapping.items(): + dtfiles.append({ "filename": v, "product_ids": f }) + + return [ + OrderedDict({ + "name": "u-boot1", + "content": { + "rawfile": { + "filename": d.getVar('UBOOT_BINARY', True), + "size": 1 + } + }, + }), + OrderedDict({ + "name": "u-boot2", + "content": { + "rawfile": { + "filename": d.getVar('UBOOT_BINARY', True), + "size": 1 + } + } + }), + OrderedDict({ + "name": "ubi", + "ubivolumes": [ + { + "name": "kernel", + "size_kib": 8192, + "content": { + "rawfile": { + "filename": d.getVar('KERNEL_IMAGETYPE', True), + "size": 5 + } + } + }, + { + "name": "dtb", + "content": { + "rawfiles": dtfiles + }, + "size_kib": 128 + }, + { + "name": "m4firmware", + "size_kib": 896 + }, + { + "name": "rootfs", + "content": { + "filesystem_type": "ubifs", + "filename": imagename + ".rootfs.tar.xz", + "uncompressed_size": rootfs_get_size(d) / 1024 + } + } + ] + })] + +python rootfs_tezi_json() { + if not bb.utils.contains("IMAGE_FSTYPES", "teziimg", True, False, d): + return + + import json + from collections import OrderedDict + + deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) + data = OrderedDict({ "config_format": 1, "autoinstall": False }) # Use image recipes SUMMARY/DESCRIPTION/PV... @@ -50,51 +168,11 @@ python rootfs_tezi_json() { data["supported_product_ids"] = d.getVar('TORADEX_PRODUCT_IDS', True).split() - imagename = d.getVar('IMAGE_NAME', True) - data["blockdevs"] = [ - OrderedDict({ - "name": "mmcblk0", - "partitions": [ - { - "partition_size_nominal": 16, - "want_maximised": False, - "content": { - "label": "BOOT", - "filesystem_type": "FAT", - "mkfs_options": "", - "filename": imagename + ".bootfs.tar.xz", - "uncompressed_size": bootfssize_kb / 1024 - } - }, - { - "partition_size_nominal": 512, - "want_maximised": True, - "content": { - "label": "RFS", - "filesystem_type": "ext3", - "mkfs_options": "", - "filename": imagename + ".rootfs.tar.xz", - "uncompressed_size": rootfssize_kb / 1024 - } - } - ] - }), - OrderedDict({ - "name": "mmcblk0boot0", - "content": { - "filesystem_type": "raw", - "rawfiles": [ - { - "filename": d.getVar('SPL_BINARY', True), - "dd_options": "seek=2" - }, - { - "filename": d.getVar('U_BOOT_BINARY', True), - "dd_options": "seek=138" - } - ] - } - })] + if bb.utils.contains("TORADEX_FLASH_TYPE", "rawnand", True, False, d): + data["mtddevs"] = rootfs_tezi_rawnand(d) + else: + data["blockdevs"] = rootfs_tezi_emmc(d) + deploy_dir = d.getVar('DEPLOY_DIR_IMAGE', True) with open(os.path.join(deploy_dir, 'image.json'), 'w') as outfile: json.dump(data, outfile, indent=4) @@ -123,7 +201,7 @@ IMAGE_CMD_teziimg () { # The first transform strips all folders from the files to tar, the # second transform "moves" them in a subfolder ${IMAGE_NAME}_${PV}. - ${IMAGE_CMD_TAR} --transform='s/.*\///' --transform 's,^,${IMAGE_NAME}_${PV}/,' -chf ${IMGDEPLOYDIR}/${IMAGE_NAME}_${TDX_VER_EXT}.tar image.json toradexlinux.png marketing.tar prepare.sh wrapup.sh ${SPL_BINARY} ${U_BOOT_BINARY} ${IMGDEPLOYDIR}/${IMAGE_NAME}.bootfs.tar.xz ${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.tar.xz + ${IMAGE_CMD_TAR} --transform='s/.*\///' --transform 's,^,${IMAGE_NAME}_${PV}/,' -chf ${IMGDEPLOYDIR}/${IMAGE_NAME}_${TDX_VER_EXT}.tar image.json toradexlinux.png marketing.tar prepare.sh wrapup.sh ${SPL_BINARY} ${UBOOT_BINARY} ${IMGDEPLOYDIR}/${IMAGE_NAME}.bootfs.tar.xz ${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.tar.xz } IMAGE_TYPEDEP_teziimg += "tar.xz" |