Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat /home/dingo/TEST3/Zipato/zipato-yocto-public/meta-zipato-public/classes/zipabox2-sdcard-image.bbclass
- inherit image_types_wic
- # This image depends on the rootfs image
- IMAGE_TYPEDEP_zipabox2-sdimg = "${SDIMG_ROOTFS_TYPE}"
- # Boot partition volume id
- BOOTDD_VOLUME_ID ?= "${MACHINE}"
- # U-Boot allocated size, at start of mmc [in MiB]
- UBOOT_SPACE ?= "4"
- # Rootfs max partition size [in MiB]
- MAX_ROOTFS_SIZE = "300"
- # Data part max size [in MiB]
- MAX_DATA_SIZE = "300"
- # Offset between partitions [in MiB]
- PART_OFFSET = "4"
- # First partition begins at UBOOT_SPACE offset
- # Use an uncompressed ext3 by default as rootfs
- SDIMG_ROOTFS_TYPE ?= "ext4"
- SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.${SDIMG_ROOTFS_TYPE}"
- do_zipabox2-sdimg[depends] += " \
- parted-native:do_populate_sysroot \
- mtools-native:do_populate_sysroot \
- dosfstools-native:do_populate_sysroot \
- virtual/kernel:do_deploy \
- virtual/bootloader:do_deploy \
- "
- # SD card image name
- SDIMG = "${IMGDEPLOYDIR}/${IMAGE_NAME}.sdimg"
- IMAGE_CMD_zipabox2-sdimg () {
- ROOTFS_A_START=${UBOOT_SPACE}
- ROOTFS_A_END=$(expr ${ROOTFS_A_START} + ${MAX_ROOTFS_SIZE})
- ROOTFS_B_START=$(expr ${ROOTFS_A_END} + ${PART_OFFSET})
- ROOTFS_B_END=$(expr ${ROOTFS_B_START} + ${MAX_ROOTFS_SIZE})
- DATA_PART_START=$(expr ${ROOTFS_B_END} + ${PART_OFFSET})
- DATA_PART_END=$(expr ${DATA_PART_START} + ${MAX_DATA_SIZE})
- # Initialize sdcard image file, not optimal at the moment, but not terribly off as well
- dd if=/dev/zero of=${SDIMG} bs=1 count=0 seek=920M
- # Create partition table
- parted -s ${SDIMG} mklabel msdos
- # Create rootfs A
- parted -s ${SDIMG} unit MiB mkpart primary ext2 ${ROOTFS_A_START} ${ROOTFS_A_END}
- # Create rootfs B
- parted -s ${SDIMG} unit MiB mkpart primary ext2 ${ROOTFS_B_START} ${ROOTFS_B_END}
- # Create data partition
- parted -s ${SDIMG} unit MiB mkpart primary ext2 ${DATA_PART_START} ${DATA_PART_END}
- parted ${SDIMG} print
- #Create data partition image
- rm -f ${WORKDIR}/data.img
- dd if=/dev/zero of=${WORKDIR}/data.img bs=1M count=${MAX_DATA_SIZE}
- rm -rf ${WORKDIR}/dataVar
- mkdir ${WORKDIR}/dataVar
- cd ${WORKDIR}/dataVar
- cp -R ${IMAGE_ROOTFS}/var ${WORKDIR}/dataVar
- if [ -d "${IMAGE_ROOTFS}/mnt/data" ]; then
- if [ ! -z "$(ls -A ${IMAGE_ROOTFS}/mnt/data)" ]; then
- cp -R ${IMAGE_ROOTFS}/mnt/data/* ${WORKDIR}/dataVar
- fi
- fi
- mkfs.ext4 -j -E stride=2,stripe-width=1024 -b 4096 -L DATA ${WORKDIR}/data.img -d ${WORKDIR}/dataVar
- # Burn Partitions
- # Rootfs A
- dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 obs=${ROOTFS_A_START}M
- # Rootfs B
- # dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 obs=${ROOTFS_B_START}M
- # Data
- dd if=${WORKDIR}/data.img of=${SDIMG} conv=notrunc seek=1 obs=${DATA_PART_START}M
- #write u-boot and spl at the beginning of sdcard
- dd if=${DEPLOY_DIR_IMAGE}/u-boot-sunxi-with-spl.bin of=${SDIMG} conv=notrunc bs=1024 seek=8
- gzip -c -1 ${SDIMG} > ${IMGDEPLOYDIR}/zipabox2-image.sdimg.gz
- }
- dingo@builder:~/TEST3/Zipato/zipato-yocto-public/build/tmp/work$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement