[ELDK] [PATCH RFSB V2] Add generation of ubifs image

Stefano Babic sbabic at denx.de
Sat Apr 24 11:41:12 CEST 2010


Add generation of a ubifs image. The resulting image
can be copied into the flash using the u-boot
"ubi writevol" command.

Signed-off-by: Stefano Babic <sbabic at denx.de>
---
 Config.in |   38 ++++++++++++++++++++++++++++++++++++++
 Makefile  |   17 +++++++++++++++--
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/Config.in b/Config.in
index 8aed288..8f16517 100644
--- a/Config.in
+++ b/Config.in
@@ -128,6 +128,44 @@ config JFFS2_ERASE_BLOCKSIZE
          going to be used on.  On NOR flashes nowadays this is usally
          greater than 64k, whereas NAND usually has 16k today.
 
+config IMAGE_UBIFS
+       bool "Create UBIFS image"
+       default n
+       help
+         Create a UBIFS image
+
+config UBIFS_MIN_IO_SIZE
+       depends IMAGE_UBIFS
+       int "minimum I/O unit size"
+       default 0
+       help
+         Minimum I/O size for the MTD device. This value
+         must be set and depends on the physical device that
+         is used. For NOR this value is usually 1,
+         for NAND is device dependent. This value can be get
+         with the mtdinfo utility on your MTD device.
+         More information under:
+         http://www.linux-mtd.infradead.org/doc/ubi.html#L_min_io_unit
+
+config UBIFS_LEB_SIZE
+       depends IMAGE_UBIFS
+       int "Default ubi leb size"
+       default 0
+       help
+         You must set this value, because it is device dependent.
+         Set the leb size as reported by mtdinfo utility.
+
+config UBIFS_MAX_LEB_COUNT
+       depends IMAGE_UBIFS
+       int "Max number leb"
+       default 0
+       help
+         This option defines the maximum file-system size
+	 (more strictly, maximum UBI volume size).
+	 This value must be set, there is no default value.
+	 More information under:
+	 http://www.linux-mtd.infradead.org/faq/ubifs.html#L_max_leb_cnt
+
 config IMAGE_CRAMFS
        bool "Create CRamFS image"
        default n
diff --git a/Makefile b/Makefile
index 22c0066..44cbaac 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,7 @@ BUILD_RFS         := $(BUILD)/rootfs
 EXT2_FILE         := $(BUILD)/images/image.ext2
 URAMDISK_FILE     := $(BUILD)/images/uRamdisk
 JFFS2_FILE        := $(BUILD)/images/image.jffs2
+UBIFS_FILE        := $(BUILD)/images/image.ubifs
 CRAMFS_FILE       := $(BUILD)/images/image.cramfs
 SQFS_DEV_TAB      := $(BUILD)/images/squashfs_devices.tab
 SQUASHFS_FILE     := $(BUILD)/images/image.squashfs
@@ -95,7 +96,7 @@ ifeq ($(strip $$($(2))),y)
 endif
 endef
 image_targets = 
-IMAGE_CONFIGS = EXT2 URAMDISK JFFS2 CRAMFS SQUASHFS
+IMAGE_CONFIGS = EXT2 URAMDISK JFFS2 CRAMFS SQUASHFS UBIFS
 $(foreach img,$(IMAGE_CONFIGS),$(eval $(call ADD_CONDITIONAL,image_targets,IMAGE_$(img),$$($(img)_FILE))))
 $(info Current target list is $(image_targets))
 
@@ -246,7 +247,7 @@ pkgs_clean:	$(TARGETS_CLEAN)
 ############################################################
 # Image targets below
 ############################################################
-.PHONY:	image_ext2 image_jffs2 image_uramdisk image_cramfs
+.PHONY:	image_ext2 image_jffs2 image_uramdisk image_cramfs ubifs_image
 
 image_ext2:	$(EXT2_FILE)
 
@@ -263,6 +264,18 @@ $(JFFS2_FILE):	$(STAMP_ROOTFS)
 	mkfs.jffs2 $(JFFS2_FLAGS) -d $(BUILD_RFS) -e $(JFFS2_ERASE_BLOCKSIZE) -D $(DEV_TAB) \
 	 -o $(JFFS2_FILE)
 
+image_ubifs:	$(UBIFS_FILE)
+
+$(UBIFS_FILE):	$(STAMP_ROOTFS)
+	@echo Generating UBIFS image
+	@if [[ $(UBIFS_LEB_SIZE) == 0 || $(UBIFS_MAX_LEB_COUNT) == 0 || $(UBIFS_MIN_IO_SIZE) == 0 ]];then \
+		echo "ERROR: You must set all the parameters for UBIFS...skipping generating image" ; \
+	else \
+	mkfs.ubifs $(UBIFS_FLAGS) --root=$(BUILD_RFS) --leb-size=$(UBIFS_LEB_SIZE) \
+		--min-io-size=$(UBIFS_MIN_IO_SIZE) \
+		--max-leb-cnt=$(UBIFS_MAX_LEB_COUNT) -o $(UBIFS_FILE); \
+	fi
+
 image_uramdisk:	$(URAMDISK_FILE)
 
 $(URAMDISK_FILE):	$(EXT2_FILE)
-- 
1.6.3.3



More information about the eldk mailing list