blob: 520ca6e62253a9665da1c59c59a35eedcc6fd1be [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
Rick Altherr92220932016-12-08 12:21:49 -08004INITRD_IMAGE ?= "obmc-phosphor-initramfs"
Rick Altherr0e7e7092017-01-04 17:25:18 -08005INITRD_LINK_NAME = "${INITRD_IMAGE}-${MACHINE}${INITRAMFS_FSTYPE}"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06006
7IMAGE_BASETYPE ?= "squashfs-xz"
Andrew Jeffery9fa01292016-02-23 23:46:58 +10308OVERLAY_BASETYPE ?= "jffs2"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06009
Brad Bishopc5361472016-02-29 10:21:51 -050010IMAGE_TYPES += "overlay"
Milton D. Miller II270cbb82016-01-20 15:36:27 -060011
Brad Bishopc5361472016-02-29 10:21:51 -050012IMAGE_TYPEDEP_overlay = "${IMAGE_BASETYPE}"
Milton D. Miller II270cbb82016-01-20 15:36:27 -060013IMAGE_TYPES_MASKED += "overlay"
14
15ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.${IMAGE_BASETYPE}"
16
Rick Altherr0e7e7092017-01-04 17:25:18 -080017FLASH_IMAGE_NAME ?= "flash-${MACHINE}-${DATETIME}"
18FLASH_IMAGE_NAME[vardepsexclude] = "DATETIME"
19FLASH_IMAGE_LINK ?= "flash-${MACHINE}"
20
21FLASH_KERNEL_IMAGETYPE ?= "fitImage"
22
23FLASH_UBOOT_OFFSET ?= "0"
24FLASH_KERNEL_OFFSET ?= "512"
25FLASH_INITRD_OFFSET ?= "3072"
26FLASH_ROFS_OFFSET ?= "4864"
27FLASH_RWFS_OFFSET ?= "28672"
28RWFS_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.
34DISTROOVERRIDES .= ":rwfs-${OVERLAY_BASETYPE}"
35
36OVERLAY_MKFS_OPTS_rwfs-ext4 = "-b 4096 -F -O^huge_file"
37
38# $(( ${FLASH_SIZE} - ${FLASH_RWFS_OFFSET} ))
39
40mk_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
47do_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}
97do_generate_flash[vardepsexclude] = "DATETIME"
98
Patrick Williams7c780e52016-06-21 14:00:16 -050099do_generate_flash[depends] += "${INITRD_IMAGE}:do_image_complete"
100do_generate_flash[depends] += "${PN}:do_image_complete"
Rick Altherr0e7e7092017-01-04 17:25:18 -0800101do_generate_flash[depends] += "u-boot:do_populate_sysroot"
Milton D. Miller II270cbb82016-01-20 15:36:27 -0600102
Brad Bishopc5361472016-02-29 10:21:51 -0500103addtask generate_flash before do_build