[U-Boot] [PATCH 5/9] spl: Add full fitImage support

Simon Glass sjg at chromium.org
Mon Jan 8 03:58:14 UTC 2018


Hi Marek,

On 28 December 2017 at 05:06, Marek Vasut <marex at denx.de> wrote:
> Add support for loading U-Boot and optionally FDT from a fitImage
> in SPL by using the full fitImage support from U-Boot. While we do
> have limited SPL loading support in SPL with a small footprint, it
> is missing a lot of important features, like checking signatures.
> This support has all the fitImage features, while the footprint is
> obviously larger.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Pantelis Antoniou <pantelis.antoniou at konsulko.com>
> Cc: Simon Glass <sjg at chromium.org>
> ---
>  Kconfig          | 11 +++++++++++
>  common/spl/spl.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 54 insertions(+)
>
> diff --git a/Kconfig b/Kconfig
> index cd32096f21..4d0c1a01c1 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -293,6 +293,17 @@ config SPL_LOAD_FIT
>           particular it can handle selecting from multiple device tree
>           and passing the correct one to U-Boot.
>
> +config SPL_LOAD_FIT_FULL
> +       bool "Enable SPL loading U-Boot as a FIT"
> +       select SPL_FIT
> +       help
> +         Normally with the SPL framework a legacy image is generated as part
> +         of the build. This contains U-Boot along with information as to
> +         where it should be loaded. This option instead enables generation

generation? Do you mean loading?

> +         of a FIT (Flat Image Tree) which provides more flexibility. In
> +         particular it can handle selecting from multiple device tree

trees

> +         and passing the correct one to U-Boot.

Can you reword this to mention the 'limited' FIT support in SPL, and
how to enable that. There needs to be a cross-reference between the
two in the docs.

> +
>  config SPL_FIT_IMAGE_POST_PROCESS
>         bool "Enable post-processing of FIT artifacts after loading by the SPL"
>         depends on SPL_LOAD_FIT
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 76c1963611..d429ea2c82 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -139,9 +139,52 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
>         spl_image->name = "U-Boot";
>  }
>
> +#ifdef CONFIG_SPL_LOAD_FIT_FULL
> +/* Parse and load full fitImage in SPL */
> +static int spl_load_fit_image(struct spl_image_info *spl_image,
> +                             const struct image_header *header)
> +
> +{
> +       bootm_headers_t images;
> +       const char *fit_uname_config = NULL;
> +       const char *fit_uname_fdt = FIT_FDT_PROP;
> +       ulong fw_data = 0, dt_data = 0;
> +       ulong fw_len = 0, dt_len = 0;
> +       int ret;
> +
> +       ret = fit_image_load(&images, (ulong)header,
> +                            NULL, &fit_uname_config,
> +                            IH_ARCH_DEFAULT, IH_TYPE_STANDALONE, -1,
> +                            FIT_LOAD_REQUIRED, &fw_data, &fw_len);
> +       if (ret < 0)
> +               return ret;
> +
> +       spl_image->size = fw_len;
> +       spl_image->entry_point = fw_data;
> +       spl_image->load_addr = fw_data;
> +       spl_image->os = IH_OS_U_BOOT;
> +       spl_image->name = "U-Boot";
> +
> +       debug("spl: payload image: %.*s load addr: 0x%lx size: %d\n",
> +               (int)sizeof(spl_image->name), spl_image->name,
> +               spl_image->load_addr, spl_image->size);
> +
> +       ret = fit_image_load(&images, (ulong)header,
> +                            &fit_uname_fdt, &fit_uname_config,
> +                            IH_ARCH_DEFAULT, IH_TYPE_FLATDT, -1,
> +                            FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
> +       return 0;
> +}
> +#endif
> +
>  int spl_parse_image_header(struct spl_image_info *spl_image,
>                            const struct image_header *header)
>  {
> +#ifdef CONFIG_SPL_LOAD_FIT_FULL

Can you use if (IS_ENABLED()) and thus avoid the #ifdef above?

> +       int ret = spl_load_fit_image(spl_image, header);
> +       if (!ret)
> +               return ret;
> +#endif
>         if (image_get_magic(header) == IH_MAGIC) {
>  #ifdef CONFIG_SPL_LEGACY_IMAGE_SUPPORT
>                 u32 header_size = sizeof(struct image_header);
> --
> 2.15.0
>

Is there a test for this code?

Regards,
Simon


More information about the U-Boot mailing list