[ELDK] [PATCH] RFSB: add support for ubi image creation with the ubifs image in it.

yes at theia.denx.de yes at theia.denx.de
Wed Jul 27 12:55:32 CEST 2011


From: Bastian Ruppert <Bastian.Ruppert at Sewerin.de>

An ubifs image created with RFSB can be placed in an ubi image.
This image can be flashed with the ubiformat utility.

Signed-off-by: Bastian Ruppert <Bastian.Ruppert at Sewerin.de>
---
 Config.in |   36 ++++++++++++++++++++++++++++++++++++
 Makefile  |   29 +++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/Config.in b/Config.in
index 03dd3ff..b75d13f 100644
--- a/Config.in
+++ b/Config.in
@@ -215,6 +215,42 @@ config IMAGE_SQUASHFS
        default n
        help
          Create a SquashFS image
+
+menu "UBI Image"
+
+config IMAGE_UBI
+       depends IMAGE_UBIFS
+       bool "Create UBI image for the UBIFS image"
+       default n
+       help
+         Create a UBI image containing the UBIFS image. This image can
+	 be flashed to a mtd device with the ubiformat tool.
+
+config UBI_CFG_VOL_NAME
+       depends IMAGE_UBI
+       string "vol_name"
+       default "rootfs"
+       help
+         This will be used for vol_name in the cfg file
+
+config UBI_ERASE_BLOCK_SIZE
+       depends IMAGE_UBI
+       int "ubi Eraseblock size in bytes"
+       default 0
+       help
+         You must set this value because it is device dependent.  Set
+	 the Eraseblock size (peb-size) as reported by the mtdinfo utility.
+
+config UBI_SUB_PAGE_SIZE
+       depends IMAGE_UBI
+       int "Sub page size"
+       default 0
+       help
+         You must set this value because it is device dependent.  Set
+	 the Sub page size as reported by the mtdinfo utility.
+
+endmenu
+
 endmenu
 
 config DATE_FILE
diff --git a/Makefile b/Makefile
index 7c40960..fb1bbc4 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,7 @@ CONFIG_DEFCONFIG   = .defconfig
 CONFIG_PACKAGES_IN = packages/Config.in
 CONFIG		   = scripts/kconfig
 BUILD		  := $(TOPDIR)/build
+AUTOGEN	          := $(BUILD)/autogen
 ifeq ($(wildcard custom/rootfs_devices.tab),)
 DEV_TAB		  := config/rootfs_devices.tab
 else
@@ -38,9 +39,12 @@ CRAMFS_FILE	  := $(BUILD)/images/image.cramfs
 EXT2_FILE	  := $(BUILD)/images/image.ext2
 JFFS2_FILE	  := $(BUILD)/images/image.jffs2
 UBIFS_FILE	  := $(BUILD)/images/image.ubifs
+UBI_FILE 	  := $(BUILD)/images/image.ubi
+UBI_CFG_FILE	  := $(AUTOGEN)/ubinize.cfg
 URAMDISK_FILE	  := $(BUILD)/images/uRamdisk
 SQFS_DEV_TAB	  := $(BUILD)/images/squashfs_devices.tab
 SQUASHFS_FILE	  := $(BUILD)/images/image.squashfs
+UBINIZE	          ?=ubinize
 
 MKDEV_SCRIPT	  := /tmp/mkdev.rfsb.tmp
 STATUS_DIR	  := status
@@ -97,7 +101,7 @@ ifeq ($(strip $$($(2))),y)
 endif
 endef
 image_targets =
-IMAGE_CONFIGS = EXT2 URAMDISK JFFS2 CRAMFS SQUASHFS UBIFS
+IMAGE_CONFIGS = EXT2 URAMDISK JFFS2 CRAMFS SQUASHFS UBIFS UBI
 $(foreach img,$(IMAGE_CONFIGS),$(eval $(call ADD_CONDITIONAL,image_targets,IMAGE_$(img),$$($(img)_FILE))))
 $(info Current target list is $(image_targets))
 
@@ -182,6 +186,7 @@ $(STAMP_CLEAN):
 	@mkdir -p $(BUILD) $(STATUS_DIR)
 	@scripts/mkdir_safe $(BUILD)/images
 	@scripts/mkdir_safe $(BUILD)/rootfs
+	@scripts/mkdir_safe $(BUILD)/autogen
 	@touch $(STAMP_CLEAN)
 
 $(STAMP_ADD_DIRS):	$(STAMP_CLEAN)
@@ -295,7 +300,7 @@ pkgs_clean:	$(TARGETS_CLEAN)
 ############################################################
 # Image targets below
 ############################################################
-.PHONY:	image_cramfs image_ext2 image_jffs2 image_ubifs image_uramdisk
+.PHONY:	image_cramfs image_ext2 image_jffs2 image_ubifs image_ubi image_uramdisk
 
 image_ext2:	$(EXT2_FILE)
 
@@ -328,6 +333,26 @@ $(UBIFS_FILE):	$(STAMP_ROOTFS)
 		--max-leb-cnt=$(UBIFS_MAX_LEB_COUNT) -o $(UBIFS_FILE); \
 	fi
 
+image_ubi: $(UBI_FILE) $(UBIFS_FILE)
+
+$(UBI_FILE):	$(STAMP_ROOTFS)
+	@echo Generating UBI image
+	@if [[ $(UBI_SUB_PAGE_SIZE) == 0 || $(UBI_ERASE_BLOCK_SIZE) == 0 ]];then \
+		echo "ERROR: Not all UBI parameters set.  Fix your configuration and try again" >&2 ; \
+	else \
+	echo "[ubifs]" > $(UBI_CFG_FILE);	\
+	echo "mode=ubi" >> $(UBI_CFG_FILE);	\
+	echo "image="$(UBIFS_FILE) >> $(UBI_CFG_FILE);	\
+	echo "vol_id=0" >> $(UBI_CFG_FILE);	\
+	echo "vol_size="$(IMAGE_SIZE)"KiB" >> $(UBI_CFG_FILE); \
+	echo "vol_type=dynamic" >> $(UBI_CFG_FILE);\
+	echo "vol_name="$(UBI_CFG_VOL_NAME) >> $(UBI_CFG_FILE);\
+	echo "vol_flags=autoresize" >> $(UBI_CFG_FILE);\
+	$(UBINIZE) --output=$(UBI_FILE) --min-io-size=$(UBIFS_MIN_IO_SIZE) \
+		--peb-size=$(UBI_ERASE_BLOCK_SIZE) --sub-page-size=$(UBI_SUB_PAGE_SIZE) \
+		$(UBI_CFG_FILE) || (rm $@; false);\
+	fi
+
 image_uramdisk:	$(URAMDISK_FILE)
 
 $(URAMDISK_FILE):	$(EXT2_FILE)
-- 
1.6.3.3



More information about the eldk mailing list