blob: 1d8272a8844349c6165b3eb5fae6dcaadcb9e563 [file] [log] [blame]
Brad Bishopc5361472016-02-29 10:21:51 -05001PACKAGES = " "
2EXCLUDE_FROM_WORLD = "1"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06003
Milton D. Miller II270cbb82016-01-20 15:36:27 -06004IMAGE_BASETYPE ?= "squashfs-xz"
Andrew Jeffery9fa01292016-02-23 23:46:58 +10305OVERLAY_BASETYPE ?= "jffs2"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06006
Brad Bishopc5361472016-02-29 10:21:51 -05007IMAGE_TYPES += "overlay"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06008
Brad Bishopc5361472016-02-29 10:21:51 -05009IMAGE_TYPEDEP_overlay = "${IMAGE_BASETYPE}"
Milton D. Miller II270cbb82016-01-20 15:36:27 -060010IMAGE_TYPES_MASKED += "overlay"
11
12ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.${IMAGE_BASETYPE}"
13
Rick Altherr0e7e7092017-01-04 17:25:18 -080014FLASH_IMAGE_NAME ?= "flash-${MACHINE}-${DATETIME}"
15FLASH_IMAGE_NAME[vardepsexclude] = "DATETIME"
16FLASH_IMAGE_LINK ?= "flash-${MACHINE}"
17
Rick Altherrc919f532017-01-11 17:33:47 -080018FLASH_KERNEL_IMAGE ?= "fitImage-${INITRAMFS_IMAGE}-${MACHINE}.bin"
Rick Altherr0e7e7092017-01-04 17:25:18 -080019
20FLASH_UBOOT_OFFSET ?= "0"
21FLASH_KERNEL_OFFSET ?= "512"
Rick Altherr0e7e7092017-01-04 17:25:18 -080022FLASH_ROFS_OFFSET ?= "4864"
23FLASH_RWFS_OFFSET ?= "28672"
24RWFS_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.
30DISTROOVERRIDES .= ":rwfs-${OVERLAY_BASETYPE}"
31
32OVERLAY_MKFS_OPTS_rwfs-ext4 = "-b 4096 -F -O^huge_file"
33
34# $(( ${FLASH_SIZE} - ${FLASH_RWFS_OFFSET} ))
35
36mk_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
43do_generate_flash() {
Rick Altherr0e7e7092017-01-04 17:25:18 -080044 ddir="${DEPLOY_DIR_IMAGE}"
Rick Altherrc919f532017-01-11 17:33:47 -080045 kernel="${FLASH_KERNEL_IMAGE}"
Rick Altherr0e7e7092017-01-04 17:25:18 -080046 uboot="u-boot.${UBOOT_SUFFIX}"
Rick Altherr0e7e7092017-01-04 17:25:18 -080047 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 Altherr0e7e7092017-01-04 17:25:18 -080056 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 Altherr0e7e7092017-01-04 17:25:18 -080071 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 Altherr0e7e7092017-01-04 17:25:18 -080080 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 Altherrc919f532017-01-11 17:33:47 -080084 tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.tar -C ${ddir} image-u-boot image-kernel image-rofs image-rwfs
Rick Altherr0e7e7092017-01-04 17:25:18 -080085}
86do_generate_flash[vardepsexclude] = "DATETIME"
87
Patrick Williams7c780e52016-06-21 14:00:16 -050088do_generate_flash[depends] += "${PN}:do_image_complete"
Rick Altherr0e7e7092017-01-04 17:25:18 -080089do_generate_flash[depends] += "u-boot:do_populate_sysroot"
Milton D. Miller II270cbb82016-01-20 15:36:27 -060090
Brad Bishopc5361472016-02-29 10:21:51 -050091addtask generate_flash before do_build