[U-Boot] [RFC PATCH v1 8/9] sp: fit: Allow the board to dynamically select the DTB overlays it needs.

Michal Simek michal.simek at xilinx.com
Mon Mar 25 09:44:41 UTC 2019


On 22. 03. 19 15:39, Jean-Jacques Hiblot wrote:
> Currently the list of DTB overlays to apply on top of the DTB is described
> in a configuration node. With this scheme, it becomes quickly hard to
> manage combinations of more than a hand few of DTB overlays. Instead the
> board could tell for each overlay if it is needed or not.
> This is the role of board_fit_get_additionnal_images().
> Note that it is not limited to dtb overlays, it could be used for kind of
> images (fpga, loadables, etc.)

You are describing this here properly. It doesn't need to be just FDT.
It can be whatever else that's why I think that this code should go out
of spl_fit_append_fdt() which is designed just for FDT.



> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
> ---
> 
>  common/spl/spl_fit.c | 28 ++++++++++++++++++++++++++++
>  include/spl.h        | 20 ++++++++++++++++++++
>  2 files changed, 48 insertions(+)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index ebce93ec1f..6e39bfa2b4 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -25,6 +25,12 @@ __weak ulong board_spl_fit_size_align(ulong size)
>  	return size;
>  }
>  
> +__weak int board_fit_get_additionnal_images(int index, const char *type,
> +					    const char **name)
> +{
> +	return -ENOENT;
> +}
> +
>  /**
>   * spl_fit_get_image_name(): By using the matching configuration subnode,
>   * retrieve the name of an image, specified by a property name and an index
> @@ -374,6 +380,28 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>  		if (ret)
>  			return ret;
>  	}
> +
> +	/* Apply overlays, the name of which are provided by board-level code */
> +	for (index = 0; ; index++) {
> +		const char *str;

better = NULL; here.


> +
> +		ret = board_fit_get_additionnal_images(index, FIT_FDT_PROP,
> +						       &str);
> +		if (ret)
> +			break;
> +		if (!str)
> +			continue;
> +
> +		node = fdt_subnode_offset(fit, images, str);
> +		if (node < 0) {
> +			pr_err("cannot find image node '%s': %d\n", str, node);
> +			continue;
> +		}
> +		ret = load_and_apply_overlay(spl_image->fdt_addr, info, sector,
> +					     fit, base_offset, node);
> +		if (ret)
> +			return ret;
> +	}

I would get this out of spl_fit_append_fdt() and make it more generic.
Then it could be easily used for generic configuration.

I think that ITS configuration should be discussed first. Right now you
have just DTB there that's why you are using FIT_FDT_PROP there.

I was using full format for these images to describe just dtbo.
                dtbo {
                        description = "DTBO";
                        data =
/incbin/("$DIR/arch/arm/dts/zynqmp-zcu100-revA-loopbk.dtbo");
                        type = "flat_dt";
                        arch = "arm";
                        compression = "none";
                        load = <0x2f00000>;
                        hash {
                                algo = "md5";
                        };
                };

Maybe we should simply introduce new type that instead of flat_dt it
will be flat_dtbo to call overlay function in dt case.


dra76-evm-dummy.dtbo {
	description = "dra76-evm-dummy.dtbo";
	data = /incbin/("arch/arm/dts/dra76-evm-dummy.dtbo");
        type = "flat_dtbo";
        arch = "arm";
        compression = "gzip";
        load = <0x2f00000>; /* optional */
        hash {
              algo = "md5";
        };
};

dra76-evm-dummy {
	description = "dra76-evm-dummy daughter card";
	fdt = "dra76-evm-dummy.dtbo";
	/* optional config, fpga, etc objects */
};


It could maybe end up in daughter card identification - finding up node
and calling the whole SPL loading mechanism again.

>  #endif
>  #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
>  	/* Try to make space, so we can inject details on the loadables */
> diff --git a/include/spl.h b/include/spl.h
> index f09909e189..5acc0a6c6e 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -370,6 +370,26 @@ void board_spl_fit_post_load(ulong load_addr, size_t length);
>   */
>  ulong board_spl_fit_size_align(ulong size);
>  
> +/**
> + * board_fit_get_additionnal_images - Get additional image names from board-

typo - additional

> + *				      level code.
> + * This function can be used to provide the image names based on runtime
> + * detection. A classic use-case would when DTBOs are used to describe
> + * additionnal daughter cards.

ditto.

> + *
> + * @param index	Index of the image. Starts at 0 and gets incremented after each
> + *		call to this function.
> + * @param type	The type of image. For example, "fdt" for DTBs
> + * @param name	Output. The name of the node describing the image. If  NULL, it
> + *		should be ignored by the caller but it does not indicate that
> + *		there no more images to get from this function.
> + *
> + * @return 0 if there are still images to get of this type to get from
> + *	   this function. Otherwise error code.
> + */
> +int board_fit_get_additionnal_images(int index, const char *type,
> +				     const char **name);
> +
>  /**
>   * spl_perform_fixups() - arch/board-specific callback before processing
>   *                        the boot-payload
> 

M


More information about the U-Boot mailing list