Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 1 | inherit image_types_uboot |
| 2 | |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 3 | INITRD_LINK_NAME = "${INITRD_IMAGE}-${MACHINE}${INITRAMFS_FSTYPE}" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 4 | |
| 5 | FLASH_IMAGE_NAME ?= "flash-${MACHINE}-${DATETIME}" |
Patrick Williams | c74dda1 | 2016-06-21 14:22:46 -0500 | [diff] [blame] | 6 | FLASH_IMAGE_NAME[vardepsexclude] = "DATETIME" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 7 | FLASH_IMAGE_LINK ?= "flash-${MACHINE}" |
| 8 | |
Rick Altherr | b08bb15 | 2017-01-09 15:44:57 -0800 | [diff] [blame] | 9 | FLASH_KERNEL_IMAGETYPE ?= "fitImage" |
Rick Altherr | 8d3d51f | 2016-07-18 22:03:55 -0700 | [diff] [blame] | 10 | |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 11 | FLASH_UBOOT_OFFSET ?= "0" |
| 12 | FLASH_KERNEL_OFFSET ?= "512" |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 13 | FLASH_INITRD_OFFSET ?= "3072" |
| 14 | FLASH_ROFS_OFFSET ?= "4864" |
| 15 | FLASH_RWFS_OFFSET ?= "28672" |
| 16 | RWFS_SIZE ?= "4096" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 17 | |
Andrew Jeffery | ecae384 | 2016-02-23 23:43:17 +1030 | [diff] [blame] | 18 | # Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However, |
| 19 | # avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are |
| 20 | # reserved for the primary image (and setting them currently breaks the build). |
| 21 | # Instead, prefix the overlay override value with 'rwfs-' to avoid collisions. |
| 22 | DISTROOVERRIDES .= ":rwfs-${OVERLAY_BASETYPE}" |
| 23 | |
| 24 | OVERLAY_MKFS_OPTS_rwfs-ext4 = "-b 4096 -F -O^huge_file" |
| 25 | |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 26 | # $(( ${FLASH_SIZE} - ${FLASH_RWFS_OFFSET} )) |
| 27 | |
| 28 | # IMAGE_POSTPROCESS_COMMAND += "do_generate_flash" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 29 | |
Andrew Jeffery | e62ee3e | 2016-02-23 23:42:06 +1030 | [diff] [blame] | 30 | mk_nor_image() { |
| 31 | image_dst="$1" |
| 32 | image_size_kb=$2 |
| 33 | dd if=/dev/zero bs=1k count=${image_size_kb} \ |
| 34 | | tr '\000' '\377' > ${image_dst} |
| 35 | } |
| 36 | |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 37 | do_generate_flash() { |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 38 | INITRD_CTYPE=${INITRAMFS_CTYPE} |
| 39 | ddir="${DEPLOY_DIR_IMAGE}" |
Rick Altherr | 8d3d51f | 2016-07-18 22:03:55 -0700 | [diff] [blame] | 40 | kernel="${FLASH_KERNEL_IMAGETYPE}" |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 41 | uboot="u-boot.${UBOOT_SUFFIX}" |
Rick Altherr | d950c53 | 2016-12-16 13:18:15 -0800 | [diff] [blame] | 42 | uinitrd="${INITRD_LINK_NAME}.cpio.${INITRD_CTYPE}.u-boot" |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 43 | rootfs="${IMAGE_LINK_NAME}.${IMAGE_BASETYPE}" |
| 44 | rwfs="rwfs.${OVERLAY_BASETYPE}" |
| 45 | |
| 46 | if [ ! -f $ddir/$kernel ]; then |
| 47 | bbfatal "Kernel file ${ddir}/${kernel} does not exist" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 48 | fi |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 49 | if [ ! -f $ddir/$uboot ]; then |
| 50 | bbfatal "U-boot file ${ddir}/${uboot} does not exist" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 51 | fi |
Rick Altherr | 74819ee | 2016-12-08 13:22:36 -0800 | [diff] [blame] | 52 | if [ ! -f $ddir/$uinitrd ]; then |
| 53 | bbfatal "uinitrd file ${ddir}/${uinitrd} does not exist" |
| 54 | fi |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 55 | if [ ! -f $ddir/$rootfs ]; then |
| 56 | bbfatal "Rootfs file ${ddir}/${rootfs} does not exist" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 57 | fi |
| 58 | |
Andrew Jeffery | e62ee3e | 2016-02-23 23:42:06 +1030 | [diff] [blame] | 59 | mk_nor_image ${ddir}/${rwfs} ${RWFS_SIZE} |
Andrew Jeffery | ecae384 | 2016-02-23 23:43:17 +1030 | [diff] [blame] | 60 | if [ "${OVERLAY_BASETYPE}" != jffs2 ]; then |
| 61 | mkfs.${OVERLAY_BASETYPE} ${OVERLAY_MKFS_OPTS} ${ddir}/${rwfs} || \ |
| 62 | bbfatal "mkfs rwfs" |
| 63 | fi |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 64 | |
| 65 | dst="${ddir}/${FLASH_IMAGE_NAME}" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 66 | rm -rf $dst |
Andrew Jeffery | e62ee3e | 2016-02-23 23:42:06 +1030 | [diff] [blame] | 67 | mk_nor_image ${dst} ${FLASH_SIZE} |
Milton Miller | 63c28b7 | 2016-06-09 10:32:21 -0500 | [diff] [blame] | 68 | dd if=${ddir}/${uboot} of=${dst} bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} |
| 69 | dd if=${ddir}/${kernel} of=${dst} bs=1k conv=notrunc seek=${FLASH_KERNEL_OFFSET} |
| 70 | dd if=${ddir}/${uinitrd} of=${dst} bs=1k conv=notrunc seek=${FLASH_INITRD_OFFSET} |
| 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} |
Milton D. Miller II | 270cbb8 | 2016-01-20 15:36:27 -0600 | [diff] [blame] | 73 | dstlink="${ddir}/${FLASH_IMAGE_LINK}" |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 74 | rm -rf $dstlink |
| 75 | ln -sf ${FLASH_IMAGE_NAME} $dstlink |
Norman James | 170f816 | 2016-01-31 22:29:26 -0600 | [diff] [blame] | 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 |
| 80 | ln -sf ${uinitrd} ${ddir}/image-initramfs |
| 81 | ln -sf ${rootfs} ${ddir}/image-rofs |
Norman James | af14977 | 2016-02-03 16:52:09 -0600 | [diff] [blame] | 82 | ln -sf ${rwfs} ${ddir}/image-rwfs |
Norman James | 170f816 | 2016-01-31 22:29:26 -0600 | [diff] [blame] | 83 | |
| 84 | tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.all.tar -C ${ddir} image-bmc |
Norman James | af14977 | 2016-02-03 16:52:09 -0600 | [diff] [blame] | 85 | tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.tar -C ${ddir} image-u-boot image-kernel image-initramfs image-rofs image-rwfs |
Brad Bishop | c654edb | 2015-10-08 14:41:20 -0400 | [diff] [blame] | 86 | } |
Patrick Williams | c74dda1 | 2016-06-21 14:22:46 -0500 | [diff] [blame] | 87 | do_generate_flash[vardepsexclude] = "DATETIME" |