[U-Boot] [RFC PATCH v1 6/9] spl: fit: Allow calling spl_load_fit_image() to only get the image size

Michal Simek michal.simek at xilinx.com
Mon Mar 25 08:12:31 UTC 2019


On 22. 03. 19 15:39, Jean-Jacques Hiblot wrote:
> To allow for dynamic allocation of the area where the image will be loaded,
> adapt spl_load_fit_image() to be able to get the size of the image without
> doing to the actual load.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
> ---
> 
>  common/spl/spl_fit.c | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index db436268cb..90bf458ee8 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -164,12 +164,15 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
>   *		If the FIT node does not contain a "load" (address) property,
>   *		the image gets loaded to the address pointed to by the
>   *		load_addr member in this struct.
> + * @no_load:	If true, the data is not loaded from the medium. Used to get
> + *		the size of the data in the case of a dynamic allocation of
> + *		the memory.
>   *
>   * Return:	0 on success or a negative error number.
>   */
>  static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  			      void *fit, ulong base_offset, int node,
> -			      struct spl_image_info *image_info)
> +			      struct spl_image_info *image_info, bool no_load)
>  {
>  	int offset;
>  	size_t length;
> @@ -216,7 +219,20 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  
>  		load_ptr = (load_addr + align_len) & ~align_len;
>  		length = len;
> +	} else {
> +		/* Embedded data */
> +		if (fit_image_get_data(fit, node, &data, &length)) {
> +			puts("Cannot get image data/size\n");
> +			return -ENOENT;
> +		}
> +	}
>  
> +	if (no_load && image_info) {
> +		image_info->size = length;
> +		return 0;
> +	}

This is return you size of image in FIT but not size of image after
uncompression. There is SPL_GZIP support and that's the size you should
work with.

M


More information about the U-Boot mailing list