[PATCH] spl: fit: List DTOs applied by SPL in U-Boot control DT

Simon Glass sjg at chromium.org
Thu Jun 27 10:37:13 CEST 2024


Hi Marek,

On Thu, 27 Jun 2024 at 00:59, Marek Vasut <marex at denx.de> wrote:
>
> Insert /u-boot,<dto-name> = <index> property into the U-Boot control DT
> during SPL DTO application process. This can be used by user to inspect
> which DTOs got applied by the SPL and in which order from running U-Boot.
>
> Example:
> ```
> u-boot=> fdt addr $fdtcontroladdr && fdt list /
> Working FDT set to aee9aeb0
> / {
>         u-boot,fdt-dto-imx8mp-dhcom-pdk3-overlay-rev100 = <0x00000005>;
>         u-boot,fdt-dto-imx8mp-dhcom-som-overlay-rev100 = <0x00000004>;
>         u-boot,fdt-dto-imx8mp-dhcom-pdk-overlay-eth2xfast = <0x00000003>;
>         u-boot,fdt-dto-imx8mp-dhcom-som-overlay-eth2xfast = <0x00000002>;
> ...
> ```
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> ---
> Cc: Manoj Sai <abbaraju.manojsai at amarulasolutions.com>
> Cc: Sean Anderson <seanga2 at gmail.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Suniel Mahesh <sunil at amarulasolutions.com>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: u-boot at dh-electronics.com
> Cc: u-boot at lists.denx.de
> ---
>  common/spl/spl_fit.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 988125be008..261b72419b1 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -363,6 +363,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>  {
>         struct spl_image_info image_info;
>         int node, ret = 0, index = 0;
> +       char dtoname[256];
>
>         /*
>          * Use the address following the image as target address for the
> @@ -450,7 +451,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>
>                         /* Make room in FDT for changes from the overlay */
>                         ret = fdt_increase_size(spl_image->fdt_addr,
> -                                               image_info.size);
> +                                               image_info.size + strlen(str));

You may also need space for the string terminator (i.e. add 1 more byte).

>                         if (ret < 0)
>                                 break;
>
> @@ -464,6 +465,26 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
>
>                         debug("%s: DT overlay %s applied\n", __func__,
>                               fit_get_name(ctx->fit, node, NULL));
> +
> +                       /*
> +                        * Insert /u-boot,<dto-name> = <index> property into
> +                        * the U-Boot control DT. This can be used by user
> +                        * to inspect which DTOs got applied by the SPL from
> +                        * a running U-Boot.
> +                        */
> +                       snprintf(dtoname, sizeof(dtoname), "u-boot,%s", str);
> +                       ret = fdt_setprop_u32(spl_image->fdt_addr, 0, dtoname,
> +                                             index);
> +                       if (!ret) {

This means there was no error, right?

> +                               /*
> +                                * The DTO itself was applied, do not treat the
> +                                * insertion of /u-boot,<dto-name> as an error
> +                                * so the system can possibly boot somehow.
> +                                */
> +                               debug("%s: DT overlay %s name not inserted into / node (%d)\n",
> +                                     __func__,
> +                                     fit_get_name(ctx->fit, node, NULL), ret);
> +                       }

log_debug()

>                 }
>                 free(tmpbuffer);
>                 if (ret)
> --
> 2.43.0
>

Regards,
Simon


More information about the U-Boot mailing list