blob: 64a8356687f46215e83720efaf8e433d8c46b95f [file] [log] [blame]
Milton D. Miller II270cbb82016-01-20 15:36:27 -06001IMAGE_BASETYPE ?= "squashfs-xz"
Andrew Jeffery9fa01292016-02-23 23:46:58 +10302OVERLAY_BASETYPE ?= "jffs2"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06003
Brad Bishopc5361472016-02-29 10:21:51 -05004IMAGE_TYPES += "overlay"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06005
Brad Bishopc5361472016-02-29 10:21:51 -05006IMAGE_TYPEDEP_overlay = "${IMAGE_BASETYPE}"
Milton D. Miller II270cbb82016-01-20 15:36:27 -06007IMAGE_TYPES_MASKED += "overlay"
8
Rick Altherr0e7e7092017-01-04 17:25:18 -08009FLASH_IMAGE_NAME ?= "flash-${MACHINE}-${DATETIME}"
10FLASH_IMAGE_NAME[vardepsexclude] = "DATETIME"
11FLASH_IMAGE_LINK ?= "flash-${MACHINE}"
12
Rick Altherrc919f532017-01-11 17:33:47 -080013FLASH_KERNEL_IMAGE ?= "fitImage-${INITRAMFS_IMAGE}-${MACHINE}.bin"
Rick Altherr0e7e7092017-01-04 17:25:18 -080014
15FLASH_UBOOT_OFFSET ?= "0"
16FLASH_KERNEL_OFFSET ?= "512"
Rick Altherr0e7e7092017-01-04 17:25:18 -080017FLASH_ROFS_OFFSET ?= "4864"
18FLASH_RWFS_OFFSET ?= "28672"
19RWFS_SIZE ?= "4096"
20
21# Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However,
22# avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are
23# reserved for the primary image (and setting them currently breaks the build).
24# Instead, prefix the overlay override value with 'rwfs-' to avoid collisions.
25DISTROOVERRIDES .= ":rwfs-${OVERLAY_BASETYPE}"
26
27OVERLAY_MKFS_OPTS_rwfs-ext4 = "-b 4096 -F -O^huge_file"
28
29# $(( ${FLASH_SIZE} - ${FLASH_RWFS_OFFSET} ))
30
31mk_nor_image() {
Brad Bishop30304a52017-07-22 14:20:20 -040032 image_dst="$1"
33 image_size_kb=$2
34 dd if=/dev/zero bs=1k count=$image_size_kb \
35 | tr '\000' '\377' > $image_dst
Rick Altherr0e7e7092017-01-04 17:25:18 -080036}
37
38do_generate_flash() {
Brad Bishop30304a52017-07-22 14:20:20 -040039 ddir="${DEPLOY_DIR_IMAGE}"
40 kernel="${FLASH_KERNEL_IMAGE}"
41 uboot="u-boot.${UBOOT_SUFFIX}"
42 rootfs="${IMAGE_LINK_NAME}.${IMAGE_BASETYPE}"
43 rwfs="rwfs.${OVERLAY_BASETYPE}"
Rick Altherr0e7e7092017-01-04 17:25:18 -080044
Brad Bishop30304a52017-07-22 14:20:20 -040045 if [ ! -f $ddir/$kernel ]; then
46 bbfatal "Kernel file $ddir/$kernel does not exist"
47 fi
48 if [ ! -f $ddir/$uboot ]; then
49 bbfatal "U-boot file $ddir/$uboot does not exist"
50 fi
51 if [ ! -f $ddir/$rootfs ]; then
52 bbfatal "Rootfs file $ddir/$rootfs does not exist"
53 fi
Rick Altherr0e7e7092017-01-04 17:25:18 -080054
Brad Bishop30304a52017-07-22 14:20:20 -040055 mk_nor_image $ddir/$rwfs ${RWFS_SIZE}
56 if [ "${OVERLAY_BASETYPE}" != jffs2 ]; then
57 mkfs.${OVERLAY_BASETYPE} ${OVERLAY_MKFS_OPTS} $ddir/$rwfs || \
58 bbfatal "mkfs rwfs"
59 fi
Rick Altherr0e7e7092017-01-04 17:25:18 -080060
Brad Bishop30304a52017-07-22 14:20:20 -040061 dst="$ddir/${FLASH_IMAGE_NAME}"
62 rm -rf $dst
63 mk_nor_image $dst ${FLASH_SIZE}
64 dd if=$ddir/$uboot of=$dst bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET}
65 dd if=$ddir/$kernel of=$dst bs=1k conv=notrunc seek=${FLASH_KERNEL_OFFSET}
66 dd if=$ddir/$rootfs of=$dst bs=1k conv=notrunc seek=${FLASH_ROFS_OFFSET}
67 dd if=$ddir/$rwfs of=$dst bs=1k conv=notrunc seek=${FLASH_RWFS_OFFSET}
68 dstlink="$ddir/${FLASH_IMAGE_LINK}"
69 rm -rf $dstlink
70 ln -sf ${FLASH_IMAGE_NAME} $dstlink
Rick Altherr0e7e7092017-01-04 17:25:18 -080071
Brad Bishop30304a52017-07-22 14:20:20 -040072 ln -sf ${FLASH_IMAGE_NAME} $ddir/image-bmc
73 ln -sf $uboot $ddir/image-u-boot
74 ln -sf $kernel $ddir/image-kernel
75 ln -sf $rootfs $ddir/image-rofs
76 ln -sf $rwfs $ddir/image-rwfs
Rick Altherr0e7e7092017-01-04 17:25:18 -080077
Brad Bishop30304a52017-07-22 14:20:20 -040078 tar -h -cvf $ddir/${MACHINE}-${DATETIME}.all.tar -C $ddir image-bmc
79 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 -080080}
81do_generate_flash[vardepsexclude] = "DATETIME"
82
Patrick Williams7c780e52016-06-21 14:00:16 -050083do_generate_flash[depends] += "${PN}:do_image_complete"
Rick Altherr0e7e7092017-01-04 17:25:18 -080084do_generate_flash[depends] += "u-boot:do_populate_sysroot"
Milton D. Miller II270cbb82016-01-20 15:36:27 -060085
Brad Bishopc5361472016-02-29 10:21:51 -050086addtask generate_flash before do_build