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