+# SD-Card Images:
+# these values are optimized for a 4GB labeled sdcard that actually holds 7744512 sectors of 512 byte
+# MBR: 2048 sectors
+# Partition 1: 32768 sectors
+# Partition 2: 98304 sectors (configurable)
+
+define Build/boot-scr
+ rm -f $@.bootscript
+ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d boot.script $@.bootscript
+endef
+
+define Build/boot-img
+ rm -f $@.boot
+ mkfs.fat -C $@.boot 16384
+ $(foreach dts,$(DEVICE_DTS), mcopy -i $@.boot $(DTS_DIR)/$(dts).dtb ::$(dts).dtb)
+ mcopy -i $@.boot $(IMAGE_KERNEL) ::zImage
+ mcopy -i $@.boot $@.bootscript ::boot.scr
+endef
+
+define Build/sdcard-img
+ ROOTFS_SIZE=$$(( $(CONFIG_TARGET_ROOTFS_PARTSIZE) * 1024 * 2 )); \
+ ./gen_mvebu_sdcard_img.sh $@ \
+ "$(BIN_DIR)/uboot-mvebu-clearfog/openwrt-mvebu-clearfog-u-boot-spl.kwb" \
+ c 32768 $@.boot \
+ 83 $$ROOTFS_SIZE $(IMAGE_ROOTFS)
+endef