Brad Bishop | 327bfd6 | 2016-02-29 10:21:51 -0500 | [diff] [blame] | 1 | PACKAGES = " " |
| 2 | EXCLUDE_FROM_WORLD = "1" |
Milton D. Miller II | ee7c120 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 3 | |
Milton D. Miller II | ee7c120 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 4 | IMAGE_BASETYPE ?= "squashfs-xz" |
Andrew Jeffery | 4e86a43 | 2016-02-23 23:46:58 +1030 | [diff] [blame] | 5 | OVERLAY_BASETYPE ?= "jffs2" |
Milton D. Miller II | ee7c120 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 6 | |
Brad Bishop | 327bfd6 | 2016-02-29 10:21:51 -0500 | [diff] [blame] | 7 | IMAGE_TYPES += "overlay" |
Milton D. Miller II | ee7c120 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 8 | |
Brad Bishop | 327bfd6 | 2016-02-29 10:21:51 -0500 | [diff] [blame] | 9 | IMAGE_TYPEDEP_overlay = "${IMAGE_BASETYPE}" |
Milton D. Miller II | ee7c120 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 10 | IMAGE_TYPES_MASKED += "overlay" |
| 11 | |
| 12 | ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.${IMAGE_BASETYPE}" |
| 13 | |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 14 | FLASH_IMAGE_NAME ?= "flash-${MACHINE}-${DATETIME}" |
| 15 | FLASH_IMAGE_NAME[vardepsexclude] = "DATETIME" |
| 16 | FLASH_IMAGE_LINK ?= "flash-${MACHINE}" |
| 17 | |
Rick Altherr | 1ed6fe3 | 2017-01-11 17:33:47 -0800 | [diff] [blame] | 18 | FLASH_KERNEL_IMAGE ?= "fitImage-${INITRAMFS_IMAGE}-${MACHINE}.bin" |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 19 | |
| 20 | FLASH_UBOOT_OFFSET ?= "0" |
| 21 | FLASH_KERNEL_OFFSET ?= "512" |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 22 | FLASH_ROFS_OFFSET ?= "4864" |
| 23 | FLASH_RWFS_OFFSET ?= "28672" |
| 24 | RWFS_SIZE ?= "4096" |
| 25 | |
| 26 | # Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However, |
| 27 | # avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are |
| 28 | # reserved for the primary image (and setting them currently breaks the build). |
| 29 | # Instead, prefix the overlay override value with 'rwfs-' to avoid collisions. |
| 30 | DISTROOVERRIDES .= ":rwfs-${OVERLAY_BASETYPE}" |
| 31 | |
| 32 | OVERLAY_MKFS_OPTS_rwfs-ext4 = "-b 4096 -F -O^huge_file" |
| 33 | |
| 34 | # $(( ${FLASH_SIZE} - ${FLASH_RWFS_OFFSET} )) |
| 35 | |
| 36 | mk_nor_image() { |
| 37 | image_dst="$1" |
| 38 | image_size_kb=$2 |
| 39 | dd if=/dev/zero bs=1k count=${image_size_kb} \ |
| 40 | | tr '\000' '\377' > ${image_dst} |
| 41 | } |
| 42 | |
| 43 | do_generate_flash() { |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 44 | ddir="${DEPLOY_DIR_IMAGE}" |
Rick Altherr | 1ed6fe3 | 2017-01-11 17:33:47 -0800 | [diff] [blame] | 45 | kernel="${FLASH_KERNEL_IMAGE}" |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 46 | uboot="u-boot.${UBOOT_SUFFIX}" |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 47 | rootfs="${IMAGE_LINK_NAME}.${IMAGE_BASETYPE}" |
| 48 | rwfs="rwfs.${OVERLAY_BASETYPE}" |
| 49 | |
| 50 | if [ ! -f $ddir/$kernel ]; then |
| 51 | bbfatal "Kernel file ${ddir}/${kernel} does not exist" |
| 52 | fi |
| 53 | if [ ! -f $ddir/$uboot ]; then |
| 54 | bbfatal "U-boot file ${ddir}/${uboot} does not exist" |
| 55 | fi |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 56 | if [ ! -f $ddir/$rootfs ]; then |
| 57 | bbfatal "Rootfs file ${ddir}/${rootfs} does not exist" |
| 58 | fi |
| 59 | |
| 60 | mk_nor_image ${ddir}/${rwfs} ${RWFS_SIZE} |
| 61 | if [ "${OVERLAY_BASETYPE}" != jffs2 ]; then |
| 62 | mkfs.${OVERLAY_BASETYPE} ${OVERLAY_MKFS_OPTS} ${ddir}/${rwfs} || \ |
| 63 | bbfatal "mkfs rwfs" |
| 64 | fi |
| 65 | |
| 66 | dst="${ddir}/${FLASH_IMAGE_NAME}" |
| 67 | rm -rf $dst |
| 68 | mk_nor_image ${dst} ${FLASH_SIZE} |
| 69 | dd if=${ddir}/${uboot} of=${dst} bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} |
| 70 | dd if=${ddir}/${kernel} of=${dst} bs=1k conv=notrunc seek=${FLASH_KERNEL_OFFSET} |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 71 | dd if=${ddir}/${rootfs} of=${dst} bs=1k conv=notrunc seek=${FLASH_ROFS_OFFSET} |
| 72 | dd if=${ddir}/${rwfs} of=${dst} bs=1k conv=notrunc seek=${FLASH_RWFS_OFFSET} |
| 73 | dstlink="${ddir}/${FLASH_IMAGE_LINK}" |
| 74 | rm -rf $dstlink |
| 75 | ln -sf ${FLASH_IMAGE_NAME} $dstlink |
| 76 | |
| 77 | ln -sf ${FLASH_IMAGE_NAME} ${ddir}/image-bmc |
| 78 | ln -sf ${uboot} ${ddir}/image-u-boot |
| 79 | ln -sf ${kernel} ${ddir}/image-kernel |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 80 | ln -sf ${rootfs} ${ddir}/image-rofs |
| 81 | ln -sf ${rwfs} ${ddir}/image-rwfs |
| 82 | |
| 83 | tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.all.tar -C ${ddir} image-bmc |
Rick Altherr | 1ed6fe3 | 2017-01-11 17:33:47 -0800 | [diff] [blame] | 84 | tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.tar -C ${ddir} image-u-boot image-kernel image-rofs image-rwfs |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 85 | } |
| 86 | do_generate_flash[vardepsexclude] = "DATETIME" |
| 87 | |
Patrick Williams | 352f50d | 2016-06-21 14:00:16 -0500 | [diff] [blame] | 88 | do_generate_flash[depends] += "${PN}:do_image_complete" |
Rick Altherr | 2a9a08a | 2017-01-04 17:25:18 -0800 | [diff] [blame] | 89 | do_generate_flash[depends] += "u-boot:do_populate_sysroot" |
Milton D. Miller II | ee7c120 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 90 | |
Brad Bishop | 327bfd6 | 2016-02-29 10:21:51 -0500 | [diff] [blame] | 91 | addtask generate_flash before do_build |