-define sanitize_profile_name
-$(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')
-endef
-
-define Image/BuildKernel/Template
- $(CP) $(LINUX_DIR)/arch/arm/boot/dts/$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
-
- $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000)
- $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb
-
- ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
- $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000,-initramfs)
- $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
- endif
-
- $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
- $(call Image/BuildKernel/MkuImage, \
- none, 0x10008000, 0x10008000, \
- $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
- $(BIN_DIR)/$(IMG_PREFIX)-uImage \
- )
-
- ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
- $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
- $(call Image/BuildKernel/MkuImage, \
- none, 0x10008000, 0x10008000, \
- $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
- $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
+#################################################
+# Images
+#################################################
+
+# build a ubi for a specific flash geometry/layout which can contain
+# volumes with the following data from ubinize-$(DEVICE_NAME).cfg:
+# - 'boot.ubifs' volume: kernel+dtbs+bootscript
+# - 'root.squashfs' volume: rootfs
+# $(1): name (used for suffix)
+# $(2): PAGESIZE (-m param to mkfs.ubifs/ubinize)
+# $(3): ERASESIZE (logical eraseblock size: -e param to mkfs.ubifs)
+# $(4): BLOCKSIZE (-p param to ubinize)
+# $(5): MAXSIZE (maximum file-system size in LEB's -c param to mkfs.ubifs)
+#
+define Build/ubi-boot-overlay
+ # ubi-boot-overlay $(DEVICE_NAME) $(word 1, $(1))
+
+ # boot filesystem
+ rm -rf $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
+ mkdir -p $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))
+ $(CP) $< $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(IMG_PREFIX)-uImage
+ ln -sf $(IMG_PREFIX)-uImage \
+ $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/uImage
+ $(foreach dts,$(shell echo $(DEVICE_DTS)), \
+ $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
+ $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb; \
+ $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/$(dts).dtb \
+ $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(IMG_PREFIX)-$(dts).dtb; \
+ ln -sf $(IMG_PREFIX)-$(dts).dtb \
+ $(TARGET_ROOTFS_DIR)/boot-$(DEVICE_NAME)_$(word 1, $(1))/$(dts).dtb; \