Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Maksym Komar <komar@evologics.de>
To: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] image_types.bbclass: add support for multiply ubifs volumes in ubi image
Date: Thu, 31 Jan 2019 10:26:12 +0100	[thread overview]
Message-ID: <20190131092612.GA20357@komar.lab.evologics.de> (raw)
In-Reply-To: <20181029090423.25375-1-komar@evologics.de>

[-- Attachment #1: Type: text/plain, Size: 5840 bytes --]

On Mon, Oct 29, 2018 at 10:04:23AM +0100, Maksym Komar wrote:

Request for feedback, please :)

> Add the ability to create additional ubifs volumes inside ubi volume.
> 
> For example this code create empty 2MiB volume named "config".
> ===
> MKUBIFS_ARGS = "-m 1 -e 65408 -c 958 -F"
> UBINIZE_ARGS = "-m 1 -p 64KiB"
> 
> MKUBIFS_VOLUMES="config rootfs"
> MKUBIFS_VOLUME_SIZE[config] = "2MiB"
> MKUBIFS_VOLUME_ARGS[config] = "-m 1 -e 65408 -c 22 -F"
> ===
> As result system will be have /dev/ubi0_0 as "config" and
> /dev/ubi0_1 as "rootfs".
> 
> Can be used with FSTYPE ubi and multiubi
> 
> Signed-off-by: Maksym Komar <komar@evologics.de>
> ---
>  meta/classes/image_types.bbclass | 67 +++++++++++++++++++++++++-------
>  1 file changed, 53 insertions(+), 14 deletions(-)
> 
> diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
> index e881d0cc2d..726760d99b 100644
> --- a/meta/classes/image_types.bbclass
> +++ b/meta/classes/image_types.bbclass
> @@ -174,28 +174,67 @@ multiubi_mkfs() {
>  		local vname="_$3"
>  	fi
>  
> -	echo \[ubifs\] > ubinize${vname}-${IMAGE_NAME}.cfg
> -	echo mode=ubi >> ubinize${vname}-${IMAGE_NAME}.cfg
> -	echo image=${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs >> ubinize${vname}-${IMAGE_NAME}.cfg
> -	echo vol_id=0 >> ubinize${vname}-${IMAGE_NAME}.cfg
> -	echo vol_type=dynamic >> ubinize${vname}-${IMAGE_NAME}.cfg
> -	echo vol_name=${UBI_VOLNAME} >> ubinize${vname}-${IMAGE_NAME}.cfg
> -	echo vol_flags=autoresize >> ubinize${vname}-${IMAGE_NAME}.cfg
> -	mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs ${mkubifs_args}
> -	ubinize -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubi ${ubinize_args} ubinize${vname}-${IMAGE_NAME}.cfg
> +	if [ -z "$4" ]; then
> +		MKUBIFS_VOLUMES="rootfs"
> +	fi
> +
> +	local vol_id=0
> +	echo -n > ubinize${vname}-${IMAGE_NAME}.cfg
> +	for volume in ${MKUBIFS_VOLUMES}; do
> +		echo \[${volume}\] >> ubinize${vname}-${IMAGE_NAME}.cfg
> +		echo mode=ubi >> ubinize${vname}-${IMAGE_NAME}.cfg
> +		echo vol_id=$vol_id >> ubinize${vname}-${IMAGE_NAME}.cfg
> +		echo vol_type=dynamic >> ubinize${vname}-${IMAGE_NAME}.cfg
> +
> +		# workaround to get Variable Flag MKUBIFS_VOLUME_SIZE[volume_name]
> +		eval ${@' '.join(['size_' + k + '=\\"' + v + '\\"' for k,v in d.getVarFlags('MKUBIFS_VOLUME_SIZE').items()])}
> +		eval size=\"\$size_$volume\"
> +
> +		if [ -z "$size" ]; then
> +			echo vol_flags=autoresize >> ubinize${vname}-${IMAGE_NAME}.cfg
> +		else
> +			echo vol_size=$size >> ubinize${vname}-${IMAGE_NAME}.cfg
> +		fi
> +
> +		if [ "${volume}" = "rootfs" ]; then
> +			echo image=${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs >> ubinize${vname}-${IMAGE_NAME}.cfg
> +			echo vol_name=${UBI_VOLNAME} >> ubinize${vname}-${IMAGE_NAME}.cfg
> +			mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs ${mkubifs_args}
> +		else
> +			echo image=${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}.${volume}.ubifs >> ubinize${vname}-${IMAGE_NAME}.cfg
> +			echo vol_name=${volume} >> ubinize${vname}-${IMAGE_NAME}.cfg
> +
> +			# workaround to get Variable Flag MKUBIFS_VOLUME_ARGS[volume_name]
> +			eval ${@' '.join(['args_' + k + '=\\"' + v + '\\"' for k,v in d.getVarFlags('MKUBIFS_VOLUME_ARGS').items()])}
> +			eval args=\"\$args_$volume\"
> +
> +	        # create empty volume
> +			mkdir -p empty
> +			mkfs.ubifs -r empty -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}.${volume}.ubifs $args
> +			rmdir empty
> +		fi
> +		vol_id=$(expr $vol_id + 1)
> +	done
> +
> +	# if variable IMAGE_NAME_SUFFIX is weak, set suffix with names of all volumes
> +	image_name_suffix=$IMAGE_NAME_SUFFIX
> +	if [ -n "${MKUBIFS_VOLUMES}" -a -z "${@d.getVar('IMAGE_NAME_SUFFIX', noweakdefault=True) or ''}" ]; then
> +		image_name_suffix=${@'.' + '-'.join(d.getVar('MKUBIFS_VOLUMES').split())}
> +	fi
> +	ubinize -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${vname}${image_name_suffix}.ubi ${ubinize_args} ubinize${vname}-${IMAGE_NAME}.cfg
>  
>  	# Cleanup cfg file
>  	mv ubinize${vname}-${IMAGE_NAME}.cfg ${IMGDEPLOYDIR}/
>  
>  	# Create own symlinks for 'named' volumes
> -	if [ -n "$vname" ]; then
> +	if [ -n "$vname" -o "${IMAGE_NAME_SUFFIX}" != "${image_name_suffix}" ]; then
>  		cd ${IMGDEPLOYDIR}
>  		if [ -e ${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs ]; then
>  			ln -sf ${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubifs \
>  			${IMAGE_LINK_NAME}${vname}.ubifs
>  		fi
> -		if [ -e ${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubi ]; then
> -			ln -sf ${IMAGE_NAME}${vname}${IMAGE_NAME_SUFFIX}.ubi \
> +		if [ -e ${IMAGE_NAME}${vname}${image_name_suffix}.ubi ]; then
> +			ln -sf ${IMAGE_NAME}${vname}${image_name_suffix}.ubi \
>  			${IMAGE_LINK_NAME}${vname}.ubi
>  		fi
>  		cd -
> @@ -208,12 +247,12 @@ IMAGE_CMD_multiubi () {
>  		eval local mkubifs_args=\"\$MKUBIFS_ARGS_${name}\"
>  		eval local ubinize_args=\"\$UBINIZE_ARGS_${name}\"
>  
> -		multiubi_mkfs "${mkubifs_args}" "${ubinize_args}" "${name}"
> +		multiubi_mkfs "${mkubifs_args}" "${ubinize_args}" "${name}" "${MKUBIFS_VOLUMES}"
>  	done
>  }
>  
>  IMAGE_CMD_ubi () {
> -	multiubi_mkfs "${MKUBIFS_ARGS}" "${UBINIZE_ARGS}"
> +	multiubi_mkfs "${MKUBIFS_ARGS}" "${UBINIZE_ARGS}" "" "${MKUBIFS_VOLUMES}"
>  }
>  
>  IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs ${MKUBIFS_ARGS}"
> -- 
> 2.19.1

-- 
EvoLogics GmbH
Ackerstraße 76, 13355 Berlin
Tel.: + 49- (0) 30- 46 06 82 26
Fax:  + 49- (0) 30- 46 06 82 15
Geschäftsführer: Dr. Rudolf Bannasch, Dr. Kostyantyn Kebkal
Amtsgericht Berlin, Charlottenburg (unter der) Nummer HR B 77787
Steuer- Nr.: 37/296/20446

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 201 bytes --]

      reply	other threads:[~2019-01-31  9:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29  9:04 [PATCH] image_types.bbclass: add support for multiply ubifs volumes in ubi image Maksym Komar
2019-01-31  9:26 ` Maksym Komar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190131092612.GA20357@komar.lab.evologics.de \
    --to=komar@evologics.de \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox