[ELDK] [PATCH] RFSB: add support for ubi image creation for the ubifs image

Detlev Zundel dzu at denx.de
Wed Jun 1 18:00:07 CEST 2011


Hi Bastian,

> 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 |   42 ++++++++++++++++++++++++++++++++++++++++++
>  Makefile  |   28 ++++++++++++++++++++++++++--
>  2 files changed, 68 insertions(+), 2 deletions(-)
>
> diff --git a/Config.in b/Config.in
> index 03dd3ff..9dcccfd 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -215,6 +215,48 @@ config IMAGE_SQUASHFS
>         default n
>         help
>           Create a SquashFS image
> +
> +menu "UBI Image"
> +
> +config UBI_UBINIZE_PREFIX
> +       string "prefix for ubinize command"
> +       default 0
> +       help
> +         Set a prefix for the ubinize tool.
> +
> +config IMAGE_UBI_1_4UBIFS
> +       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_1_CFG_VOL_NAME
> +       depends IMAGE_UBI_1_4UBIFS
> +       string "vol_name"
> +       default "rootfs"
> +       help
> +         This will be used for vol_name in the cfg file
> +
> +config UBI_1_ERASE_BLOCK_SIZE
> +       depends IMAGE_UBI_1_4UBIFS
> +       int "ubi Eraseblock size in KiB"
> +       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_1_SUB_PAGE_SIZE
> +       depends IMAGE_UBI_1_4UBIFS
> +       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..9791ed0 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,6 +39,8 @@ 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_1_4UBIFS_FILE := $(BUILD)/images/image.ubi
> +UBI_1_CFG_FILE	  := $(AUTOGEN)/ubinize_4ubifs.cfg
>  URAMDISK_FILE	  := $(BUILD)/images/uRamdisk
>  SQFS_DEV_TAB	  := $(BUILD)/images/squashfs_devices.tab
>  SQUASHFS_FILE	  := $(BUILD)/images/image.squashfs
> @@ -97,7 +100,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_1_4UBIFS
>  $(foreach img,$(IMAGE_CONFIGS),$(eval $(call ADD_CONDITIONAL,image_targets,IMAGE_$(img),$$($(img)_FILE))))
>  $(info Current target list is $(image_targets))
>  
> @@ -182,6 +185,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 +299,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_4ubifs image_uramdisk
>  
>  image_ext2:	$(EXT2_FILE)
>  
> @@ -328,6 +332,26 @@ $(UBIFS_FILE):	$(STAMP_ROOTFS)
>  		--max-leb-cnt=$(UBIFS_MAX_LEB_COUNT) -o $(UBIFS_FILE); \
>  	fi
>  
> +image_ubi_4ubifs: $(UBI_1_FILE) $(UBIFS_FILE)
> +
> +$(UBI_1_4UBIFS_FILE):	$(STAMP_ROOTFS)
> +	@echo Generating UBI image
> +	@if [[ $(UBI_1_SUB_PAGE_SIZE) == 0 || $(UBI_1_ERASE_BLOCK_SIZE) == 0 ]];then \
> +		echo "ERROR: Not all UBI_1 parameters set.  Fix your configuration and try again" >&2 ; \
> +	else \
> +	echo "[ubifs]" > $(UBI_1_CFG_FILE);	\
> +	echo "mode=ubi" >> $(UBI_1_CFG_FILE);	\
> +	echo "image="$(UBIFS_FILE) >> $(UBI_1_CFG_FILE);	\
> +	echo "vol_id=0" >> $(UBI_1_CFG_FILE);	\
> +	echo "vol_size="$(IMAGE_SIZE)"KiB" >> $(UBI_1_CFG_FILE); \
> +	echo "vol_type=dynamic" >> $(UBI_1_CFG_FILE);\
> +	echo "vol_name="$(UBI_1_CFG_VOL_NAME) >> $(UBI_1_CFG_FILE);\
> +	echo "vol_flags=autoresize" >> $(UBI_1_CFG_FILE);\
> +	$(UBI_UBINIZE_PREFIX)ubinize --output=$(UBI_1_4UBIFS_FILE) --min-io-size=$(UBIFS_MIN_IO_SIZE) \
> +		--peb-size=$(UBI_1_ERASE_BLOCK_SIZE)KiB --sub-page-size=$(UBI_1_SUB_PAGE_SIZE) \
> +		$(UBI_1_CFG_FILE);\
> +	fi
> +
>  image_uramdisk:	$(URAMDISK_FILE)
>  
>  $(URAMDISK_FILE):	$(EXT2_FILE)

To be honest, I'm not too happy about the "UBI_1_" variable names.  From
a casual glance I would have no idea what they mean.  Please rename them
into simple "UBI_".  It would probably be nice to have a selection of
possible UBI configurations, but this is beyond the current usage and
left as an excercise to the reader ;)

So I am waiting for another version addressing this and the comments of
Wolfgang.  Thanks!
  Detlev

-- 
Those who deny freedom to others deserve it not for themselves.
           -- Abraham Lincoln
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de


More information about the eldk mailing list