Advertisement
Guest User

Untitled

a guest
Jul 1st, 2021
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. cat /home/dingo/TEST3/Zipato/zipato-yocto-public/meta-zipato-public/classes/zipabox2-sdcard-image.bbclass
  2. inherit image_types_wic
  3.  
  4. # This image depends on the rootfs image
  5. IMAGE_TYPEDEP_zipabox2-sdimg = "${SDIMG_ROOTFS_TYPE}"
  6.  
  7. # Boot partition volume id
  8. BOOTDD_VOLUME_ID ?= "${MACHINE}"
  9.  
  10. # U-Boot allocated size, at start of mmc [in MiB]
  11. UBOOT_SPACE ?= "4"
  12.  
  13. # Rootfs max partition size [in MiB]
  14. MAX_ROOTFS_SIZE = "300"
  15.  
  16. # Data part max size [in MiB]
  17. MAX_DATA_SIZE = "300"
  18.  
  19. # Offset between partitions [in MiB]
  20. PART_OFFSET = "4"
  21.  
  22. # First partition begins at UBOOT_SPACE offset
  23. # Use an uncompressed ext3 by default as rootfs
  24. SDIMG_ROOTFS_TYPE ?= "ext4"
  25. SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.${SDIMG_ROOTFS_TYPE}"
  26.  
  27. do_zipabox2-sdimg[depends] += " \
  28. parted-native:do_populate_sysroot \
  29. mtools-native:do_populate_sysroot \
  30. dosfstools-native:do_populate_sysroot \
  31. virtual/kernel:do_deploy \
  32. virtual/bootloader:do_deploy \
  33. "
  34. # SD card image name
  35. SDIMG = "${IMGDEPLOYDIR}/${IMAGE_NAME}.sdimg"
  36.  
  37. IMAGE_CMD_zipabox2-sdimg () {
  38.  
  39. ROOTFS_A_START=${UBOOT_SPACE}
  40. ROOTFS_A_END=$(expr ${ROOTFS_A_START} + ${MAX_ROOTFS_SIZE})
  41. ROOTFS_B_START=$(expr ${ROOTFS_A_END} + ${PART_OFFSET})
  42. ROOTFS_B_END=$(expr ${ROOTFS_B_START} + ${MAX_ROOTFS_SIZE})
  43. DATA_PART_START=$(expr ${ROOTFS_B_END} + ${PART_OFFSET})
  44. DATA_PART_END=$(expr ${DATA_PART_START} + ${MAX_DATA_SIZE})
  45.  
  46. # Initialize sdcard image file, not optimal at the moment, but not terribly off as well
  47. dd if=/dev/zero of=${SDIMG} bs=1 count=0 seek=920M
  48.  
  49. # Create partition table
  50. parted -s ${SDIMG} mklabel msdos
  51.  
  52. # Create rootfs A
  53. parted -s ${SDIMG} unit MiB mkpart primary ext2 ${ROOTFS_A_START} ${ROOTFS_A_END}
  54.  
  55. # Create rootfs B
  56. parted -s ${SDIMG} unit MiB mkpart primary ext2 ${ROOTFS_B_START} ${ROOTFS_B_END}
  57.  
  58. # Create data partition
  59. parted -s ${SDIMG} unit MiB mkpart primary ext2 ${DATA_PART_START} ${DATA_PART_END}
  60.  
  61. parted ${SDIMG} print
  62.  
  63. #Create data partition image
  64. rm -f ${WORKDIR}/data.img
  65. dd if=/dev/zero of=${WORKDIR}/data.img bs=1M count=${MAX_DATA_SIZE}
  66. rm -rf ${WORKDIR}/dataVar
  67. mkdir ${WORKDIR}/dataVar
  68. cd ${WORKDIR}/dataVar
  69. cp -R ${IMAGE_ROOTFS}/var ${WORKDIR}/dataVar
  70. if [ -d "${IMAGE_ROOTFS}/mnt/data" ]; then
  71. if [ ! -z "$(ls -A ${IMAGE_ROOTFS}/mnt/data)" ]; then
  72. cp -R ${IMAGE_ROOTFS}/mnt/data/* ${WORKDIR}/dataVar
  73. fi
  74. fi
  75. mkfs.ext4 -j -E stride=2,stripe-width=1024 -b 4096 -L DATA ${WORKDIR}/data.img -d ${WORKDIR}/dataVar
  76.  
  77. # Burn Partitions
  78.  
  79. # Rootfs A
  80. dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 obs=${ROOTFS_A_START}M
  81. # Rootfs B
  82. # dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 obs=${ROOTFS_B_START}M
  83. # Data
  84. dd if=${WORKDIR}/data.img of=${SDIMG} conv=notrunc seek=1 obs=${DATA_PART_START}M
  85.  
  86. #write u-boot and spl at the beginning of sdcard
  87. dd if=${DEPLOY_DIR_IMAGE}/u-boot-sunxi-with-spl.bin of=${SDIMG} conv=notrunc bs=1024 seek=8
  88.  
  89. gzip -c -1 ${SDIMG} > ${IMGDEPLOYDIR}/zipabox2-image.sdimg.gz
  90.  
  91. }
  92. dingo@builder:~/TEST3/Zipato/zipato-yocto-public/build/tmp/work$
  93.  
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement