From: Chee, Tien Fong <tien.fong.chee@intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 2/2] common: Generic firmware loader for file system
Date: Tue, 23 Jan 2018 06:28:45 +0000 [thread overview]
Message-ID: <1516688925.2740.13.camel@intel.com> (raw)
In-Reply-To: <3144af0e-2914-cbee-0b5f-12213150d205@de.pepperl-fuchs.com>
On Mon, 2018-01-22 at 12:41 +0100, Simon Goldschmidt wrote:
> On 22.01.2018 09:08, Chee, Tien Fong wrote:
> >
> > On Thu, 2018-01-18 at 06:57 +0100, Simon Goldschmidt wrote:
> > >
> > > On 27.12.2017 06:04, tien.fong.chee at intel.com wrote:
> > > >
> > > > From: Tien Fong Chee <tien.fong.chee@intel.com>
> > > >
> > > > This is file system generic loader which can be used to load
> > > > the file image from the storage into target such as memory.
> > > > The consumer driver would then use this loader to program
> > > > whatever,
> > > > ie. the FPGA device.
> > > >
> > > > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> > > > ---
> > > > common/Makefile | 1 +
> > > > common/fs_loader.c | 309
> > > > +++++++++++++++++++++++++++++++++++++++++++++
> > > > doc/README.firmware_loader | 76 +++++++++++
> > > > include/fs_loader.h | 28 ++++
> > > > 4 files changed, 414 insertions(+)
> > > > create mode 100644 common/fs_loader.c
> > > > create mode 100644 doc/README.firmware_loader
> > > > create mode 100644 include/fs_loader.h
> > > <snip>
> > >
> > > >
> > > > +#if defined(CONFIG_SPL_MMC_SUPPORT) &&
> > > > defined(CONFIG_SPL_BUILD)
> > > > +static int init_mmc(void)
> > > > +{
> > > > + /* Just for the case MMC is not yet initialized */
> > > > + struct mmc *mmc = NULL;
> > > > + int err;
> > > > +
> > > > + spl_mmc_find_device(&mmc, spl_boot_device());
> > > > +
> > > > + err = mmc_init(mmc);
> > > > + if (err) {
> > > > + printf("spl: mmc init failed with error:
> > > > %d\n",
> > > > err);
> > > > + return err;
> > > > + }
> > > > +
> > > > + return err;
> > > > +}
> > > I see two problems here: First, you're ignoring the return value
> > > of
> > > spl_mmc_find_device() and initialize 'mmc' to NULL instead.
> > > Wouldn't
> > > it
> > > be better to let 'mmc' be uninitialized and return the error code
> > > returned by spl_mmc_find_device() if there is one?
> > >
> > Yeah, you are right, i should add the check on the return value. I
> > think that would better to initialize NULL to mmc, because there is
> > no
> > checking on the mmc in spl_mmc_find_device(), so that is possible
> > memory access violation/abort can be happended if unknown value in
> > mmc
> > pointer.
> >
> > >
> > > Second, using spl_boot_device() would prevent making the loader
> > > work
> > > on
> > > mach-socfpga when spl is not loaded from mmc, right?
> > >
> > > E.g. for the case I'm currently trying to fix (boot from qspi),
> > > this
> > > loader would not work although there's technically no reason
> > > since
> > > the
> > > platform only has one mmc. The call to spl_boot_device() could be
> > > replaced by the exact value here for platforms that only have one
> > > mmc. I
> > > don't know how to fix that, though.
> > >
> > The main purpose here is to initialize the mmc driver. So which
> > storage
> > user wants to load the file is totally depend what storage such as
> > mmc
> > user defines in location->name. Loader would init the storage based
> > on
> > the storage defined in location->name before accessing it. Since
> > the
> > loader only support file system at this moment, i would suggest FAT
> > fs
> > for mmc and ubi fs for qspi.
> What I meant to say is this: at least on mach-socfpga, from reading
> the
> code, I cannot load a file from mmc when booting from qspi, as
> 'spl_boot_device' returns 'BOOT_DEVICE_SPI' in that case, although I
> need to pass 'BOOT_DEVICE_MMC1' to 'spl_mmc_find_device'. Or am I
> wrong
> here?
>
Okay, i got you.
Yeah, you are right for use case if you need to load the file from mmc
during SPL boot and SPL is not loaded from mmc.
Since the spl_boot_device is platform dependent, you may try to add
some state machine so that this function can return correct device
type.
Secondly, you can use this function in U-Boot instead of SPL.
Lastly, i can declare __Weak to init_mmc, so that user can define their
own implementation.
> Regards,
> Simon
next prev parent reply other threads:[~2018-01-23 6:28 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-27 5:04 [U-Boot] [PATCH v6 0/2] Generic firmware loader tien.fong.chee at intel.com
2017-12-27 5:04 ` [U-Boot] [PATCH v6 1/2] spl: Remove static declaration on spl_mmc_find_device function tien.fong.chee at intel.com
2018-01-15 16:35 ` [U-Boot] [U-Boot, v6, " Tom Rini
2017-12-27 5:04 ` [U-Boot] [PATCH v6 2/2] common: Generic firmware loader for file system tien.fong.chee at intel.com
2018-01-15 16:36 ` [U-Boot] [U-Boot, v6, " Tom Rini
2018-01-16 7:58 ` Chee, Tien Fong
2018-01-16 14:35 ` Tom Rini
2018-01-18 3:42 ` Chee, Tien Fong
2018-01-18 13:18 ` Tom Rini
2018-01-22 6:37 ` Chee, Tien Fong
2018-01-16 14:41 ` [U-Boot] [PATCH v6 " Marek Vasut
2018-01-18 4:33 ` Chee, Tien Fong
2018-01-18 11:12 ` Marek Vasut
2018-01-22 7:11 ` Chee, Tien Fong
2018-01-22 8:44 ` Lothar Waßmann
2018-01-23 4:28 ` Chee, Tien Fong
2018-01-22 12:41 ` Marek Vasut
2018-01-18 5:57 ` Simon Goldschmidt
2018-01-22 8:08 ` Chee, Tien Fong
2018-01-22 11:41 ` Simon Goldschmidt
2018-01-23 6:28 ` Chee, Tien Fong [this message]
2018-01-23 7:52 ` Simon Goldschmidt
2018-01-23 7:58 ` Simon Goldschmidt
2018-01-23 8:31 ` Chee, Tien Fong
2018-01-23 9:13 ` Simon Goldschmidt
2018-01-24 5:13 ` Chee, Tien Fong
2018-01-24 5:34 ` Simon Goldschmidt
2018-01-03 8:46 ` [U-Boot] [PATCH v6 0/2] Generic firmware loader Chee, Tien Fong
2018-01-08 8:07 ` Lothar Waßmann
2018-01-09 5:26 ` Chee, Tien Fong
2018-01-15 6:57 ` Chee, Tien Fong
2018-01-15 6:50 ` Chee, Tien Fong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516688925.2740.13.camel@intel.com \
--to=tien.fong.chee@intel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox