[U-Boot] [PATCH] splash: add support for loading splash from a FIT image

Simon Glass sjg at chromium.org
Thu Nov 24 03:20:31 CET 2016


Hi Tomas,

On 21 November 2016 at 01:27, Tomas Melin <tomas.melin at vaisala.com> wrote:
> Enable support for loading a splash image from within a FIT image.
> The image is assumed to be generated with mkimage -E flag to hold
> the data external to the FIT.
>
> Signed-off-by: Tomas Melin <tomas.melin at vaisala.com>
> ---
>  common/splash_source.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/splash.h       |  1 +
>  2 files changed, 74 insertions(+)
>
> diff --git a/common/splash_source.c b/common/splash_source.c
> index 72df2c1..d72aee1 100644
> --- a/common/splash_source.c
> +++ b/common/splash_source.c
> @@ -16,6 +16,7 @@
>  #include <sata.h>
>  #include <bmp_layout.h>
>  #include <fs.h>
> +#include <fdt_support.h>

Can you please add a new patch to sort the includes?

http://www.denx.de/wiki/U-Boot/CodingStyle

>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -295,6 +296,74 @@ static struct splash_location *select_splash_location(
>         return NULL;
>  }
>
> +#ifdef CONFIG_FIT
> +static int splash_load_fit(struct splash_location *location, u32 bmp_load_addr)

Is it possible to use fit_image_load() here instead of writing a new
function? I suppose not, since you need to load the data from an
external source. Can we at least put the code to read the details into
image.c, in a new function? Then this file can call it - it can return
a struct with the info, or a few parameters, perhaps.

Also please see spl_load_simple_fit() where you might find some common code.

> +{
> +       int res;
> +       int node_offset;
> +       int splash_offset;
> +       int splash_size;
> +       const fdt32_t *val;
> +       struct image_header *img_header;
> +       const u32 *fit_header;
> +       u32 fit_size;
> +       const size_t header_size = sizeof(struct image_header);
> +
> +       /* Read in image header */
> +       res = splash_storage_read_raw(location, bmp_load_addr, header_size);
> +       if (res < 0)
> +               return res;
> +
> +       img_header = (struct image_header*)bmp_load_addr;
> +       fit_size = fdt_totalsize(img_header);
> +
> +       fit_header = (const u32*)(bmp_load_addr + header_size);
> +       /* Read in entire FIT */
> +       res = splash_storage_read_raw(location, (u32)fit_header, fit_size);
> +       if (res < 0)
> +               return res;
> +
> +       res = fit_check_format(fit_header);
> +       if (!res) {
> +               printf("Could not find valid FIT-image\n");
> +               return -EINVAL;
> +       }
> +
> +       node_offset = fit_image_get_node(fit_header, location->name);
> +       if (node_offset < 0) {
> +               printf("Could not find splash image '%s' in FIT\n",
> +                      location->name);
> +               return -ENOENT;
> +       }
> +
> +       val = fdt_getprop(fit_header, node_offset, "data-offset", NULL);
> +       if (!val) {
> +               printf("Could not find 'data-offset' property in FIT\n");
> +               return -ENOENT;
> +       }
> +       splash_offset = fdt32_to_cpu(*val);
> +
> +       val = fdt_getprop(fit_header, node_offset, "data-size", NULL);
> +       if (!val) {
> +               printf("Could not find 'data-size' property in FIT\n");
> +               return -ENOENT;
> +       }
> +       splash_size = fdt32_to_cpu(*val);
> +
> +       /* Align data offset to 4-byte boundrary */
> +       fit_size = fdt_totalsize(fit_header);
> +       fit_size = (fit_size + 3) & ~3;
> +
> +       /* Read in the splash data */
> +       location->offset = (location->offset + fit_size + splash_offset);
> +       res = splash_storage_read_raw(location, bmp_load_addr , splash_size);
> +       if (res < 0)
> +               return res;
> +
> +       return 0;
> +}
> +#endif /* CONFIG_FIT */
> +
>  /**
>   * splash_source_load - load splash image from a supported location.
>   *
> @@ -331,5 +400,9 @@ int splash_source_load(struct splash_location *locations, uint size)
>                 return splash_load_raw(splash_location, bmp_load_addr);
>         else if (splash_location->flags == SPLASH_STORAGE_FS)
>                 return splash_load_fs(splash_location, bmp_load_addr);
> +#ifdef CONFIG_FIT
> +       else if (splash_location->flags == SPLASH_STORAGE_FIT)
> +               return splash_load_fit(splash_location, bmp_load_addr);
> +#endif
>         return -EINVAL;
>  }
> diff --git a/include/splash.h b/include/splash.h
> index 136eac7..af4e61f 100644
> --- a/include/splash.h
> +++ b/include/splash.h
> @@ -35,6 +35,7 @@ enum splash_storage {
>  enum splash_flags {
>         SPLASH_STORAGE_RAW,
>         SPLASH_STORAGE_FS,
> +       SPLASH_STORAGE_FIT,
>  };

Can you comment that enum please?

>
>  struct splash_location {
> --
> 2.1.4
>

Regards,
Simon


More information about the U-Boot mailing list