[PATCH v3 4/5] spl: Support loading a FIT from ext FS

Mayuresh Chitale mchitale at ventanamicro.com
Sat Jun 3 10:21:22 CEST 2023


On Fri, May 5, 2023 at 6:11 AM Simon Glass <sjg at chromium.org> wrote:
>
> Hi Mayuresh,
>
> On Thu, 4 May 2023 at 03:53, Mayuresh Chitale <mchitale at ventanamicro.com> wrote:
> >
> > Detect a FIT when loading from an ext File system and handle it using
> > the FIT SPL support.
> >
> > Signed-off-by: Mayuresh Chitale <mchitale at ventanamicro.com>
> > ---
> >  common/spl/spl_ext.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
> > index f117c630bf..7b771c41e9 100644
> > --- a/common/spl/spl_ext.c
> > +++ b/common/spl/spl_ext.c
> > @@ -8,6 +8,26 @@
> >  #include <ext4fs.h>
> >  #include <errno.h>
> >  #include <image.h>
> > +#include <linux/libfdt.h>
> > +
> > +static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,
> > +                         ulong size, void *buf)
> > +{
> > +       loff_t filelen = (loff_t)load->priv, actlen;
> > +       char *filename = (char *)load->filename;
> > +       int ret;
> > +
> > +       ret = ext4fs_read(buf, file_offset, filelen, &actlen);
>
> If you use the fs_...() interface instead, can you make this function
> generic for all filesystems?
Ok.
>
> > +       if (ret < 0) {
> > +               if (IS_ENABLED(CONFIG_SPL_LIBCOMMON_SUPPORT)) {
> > +                       printf("%s: error reading image %s, err - %d\n",
> > +                              __func__, filename, ret);
>
> I could be wrong, but I think printf() is silently dropped if that
> option is not enabled, so maybe you don't need the if() checK?
>
> > +               }
> > +               return ret;
> > +       }
> > +
> > +       return actlen;
> > +}
> >
> >  int spl_load_image_ext(struct spl_image_info *spl_image,
> >                        struct spl_boot_device *bootdev,
> > @@ -47,6 +67,19 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
>
> Really this should not be different from FAT and other filesystems.
> I'm not sure what is involved in making it common, though.
Yes, it can be made generic.
>
> >                 goto end;
> >         }
> >
> > +       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
> > +           image_get_magic(header) == FDT_MAGIC) {
> > +               struct spl_load_info load;
> > +
> > +               debug("Found FIT\n");
> > +               load.read = spl_fit_read;
> > +               load.bl_len = 1;
> > +               load.filename = (void *)filename;
> > +               load.priv = (void *)filelen;
> > +
> > +               return spl_load_simple_fit(spl_image, &load, 0, header);
> > +       }
> > +
> >         err = spl_parse_image_header(spl_image, bootdev, header);
> >         if (err < 0) {
> >                 puts("spl: ext: failed to parse image header\n");
> > --
> > 2.34.1
> >
>
> Regards,
> Simon


More information about the U-Boot mailing list