endchoice
+config BR2_TARGET_ROOTFS_UBI
+ depends on BR2_TARGET_ROOTFS_UBIFS
+ bool "Embed into an UBI image"
+ help
+ Build an ubi image from the ubifs one (with ubinize).
+
+config BR2_TARGET_ROOTFS_UBI_PEBSIZE
+ hex "UBI physical erase block size"
+ depends on BR2_TARGET_ROOTFS_UBI
+ default 0x20000
+ help
+ Tells ubinize the physical eraseblock size of the flash chip
+ the ubi image is created for.
+
+config BR2_TARGET_ROOTFS_UBI_SUBSIZE
+ int "UBI sub-page size"
+ depends on BR2_TARGET_ROOTFS_UBI
+ default 512
+ help
+ Tells ubinize that the flash supports sub-pages and the sub-page
+ size. Use 0 if subpages are not supported on flash chip.
--- /dev/null
+#############################################################
+#
+# Embed the ubifs image into an ubi one
+#
+#############################################################
+
+UBI_UBINIZE_OPTS := -m $(BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE)
+UBI_UBINIZE_OPTS += -p $(BR2_TARGET_ROOTFS_UBI_PEBSIZE)
+ifneq ($(BR2_TARGET_ROOTFS_UBI_SUBSIZE),0)
+UBI_UBINIZE_OPTS += -s $(BR2_TARGET_ROOTFS_UBI_SUBSIZE)
+endif
+
+ROOTFS_UBI_DEPENDENCIES = rootfs-ubifs
+
+define ROOTFS_UBI_CMD
+ cp fs/ubifs/ubinize.cfg . ;\
+ echo "image=$$@fs" \
+ >> ./ubinize.cfg ;\
+ $(HOST_DIR)/usr/sbin/ubinize -o $$@ $(UBI_UBINIZE_OPTS) ubinize.cfg ;\
+ rm ubinize.cfg
+endef
+
+$(eval $(call ROOTFS_TARGET,ubi))