From: Chee, Tien Fong <tien.fong.chee@intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
Date: Thu, 22 Feb 2018 08:18:01 +0000 [thread overview]
Message-ID: <1519287480.9210.14.camel@intel.com> (raw)
In-Reply-To: <6406826c-2092-a616-1adc-d3c8f735d1a8@denx.de>
On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote:
> On 02/05/2018 08:06 AM, 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>
> > Reviewed-by: Lothar Waßmann <LW@KARO-electronics.de>
> [...]
>
> >
> > +#include <common.h>
> > +#include <errno.h>
> > +#include <fs.h>
> > +#include <fs_loader.h>
> > +#include <nand.h>
> > +#include <sata.h>
> > +#include <spi.h>
> > +#include <spi_flash.h>
> > +#ifdef CONFIG_SPL
> Are the ifdefs needed ?
>
Because spl.h contains some codes have its dependency with SPL. So, Tom
adviced to make this part of code depend on CONFIG_SPL.
However, only __weak int init_mmc() depend on the codes from spl.h, so
user can override their own init_mmc() if SPL is not used.
> >
> > +#include <spl.h>
> > +#endif
> > +#include <linux/string.h>
> > +#ifdef CONFIG_CMD_UBIFS
> > +#include <ubi_uboot.h>
> > +#include <ubifs_uboot.h>
> > +#endif
> > +#include <usb.h>
> > +
> > +struct firmware_priv {
> > + const char *name; /* Filename */
> > + u32 offset; /* Offset of reading a file */
> > +};
> > +
> > +static struct device_location default_locations[] = {
> > + {
> > + .name = "mmc",
> > + .devpart = "0:1",
> > + },
> > + {
> > + .name = "usb",
> > + .devpart = "0:1",
> > + },
> > + {
> > + .name = "sata",
> > + .devpart = "0:1",
> > + },
> How can this load from UBI if it's not listed here ?
>
> >
> > +};
> > +
> > +/* USB build is not supported yet in SPL */
> > +#ifndef CONFIG_SPL_BUILD
> > +#ifdef CONFIG_USB_STORAGE
> > +static int init_usb(void)
> > +{
> > + int err;
> > +
> > + err = usb_init();
> > + if (err)
> > + return err;
> > +
> > +#ifndef CONFIG_DM_USB
> > + err = usb_stor_scan(1);
> mode = 0 I think, we don't need this verbose output.
>
Okay so i will change to usb_stor_scan(0) .
> >
> > + if (err)
> > + return err;
> > +#endif
> > +
> > + return err;
> > +}
> > +#else
> > +static int init_usb(void)
> > +{
> > + debug("Error: Cannot load flash image: no USB support\n");
> > + return -ENOSYS;
> > +}
> > +#endif
> > +#endif
> > +
> > +#ifdef CONFIG_SATA
> > +static int init_storage_sata(void)
> > +{
> > + return sata_probe(0);
> Shouldn't the sata device number be pulled from devpart in
> default_locations table ?
>
This may need to add the logic for splitting the device number and
partition into integer from the string. Let me think how to do it, may
be i can leverage existing code.
> >
> > +}
> > +#else
> > +static int init_storage_sata(void)
> > +{
> > + debug("Error: Cannot load image: no SATA support\n");
> > + return -ENOSYS;
> > +}
> > +#endif
> > +
> > +#ifdef CONFIG_CMD_UBIFS
> > +static int mount_ubifs(struct device_location *location)
> > +{
> > + int ret;
> > + char cmd[32];
> > +
> > + if (ret = ubi_part(location->mtdpart, NULL)) {
> > + debug("Cannot find mtd partition %s\n", location-
> > >mtdpart);
> > + return ret;
> > + }
> > +
> > + return cmd_ubifs_mount(location->ubivol);
> > +}
> > +
> > +static int umount_ubifs(void)
> > +{
> > + return cmd_ubifs_umount();
> > +}
> > +#else
> > +static int mount_ubifs(struct device_location *location)
> > +{
> > + debug("Error: Cannot load image: no UBIFS support\n");
> > + return -ENOSYS;
> > +}
> > +#endif
> > +
> > +#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD)
> > +__weak int init_mmc(void)
> > +{
> > + /* Just for the case MMC is not yet initialized */
> > + struct mmc *mmc = NULL;
> > + int err;
> > +
> > +#ifdef CONFIG_SPL
> > + spl_mmc_find_device(&mmc, spl_boot_device());
> > +#else
> > + debug("#define CONFIG_SPL is required or overrriding
> > %s\n",
> > + __func__);
> This can be a compile-time error, maybe ?
>
No compile error. When you open the file, "%s\n" is actually same line
with debug("..... .
> >
> > + return -ENOENT;
> > +#endif
> > +
> > + err = mmc_init(mmc);
> > + if (err) {
> > + debug("spl: mmc init failed with error: %d\n",
> > err);
> > + return err;
> > + }
> > +
> > + return err;
> > +}
> > +#else
> > +__weak int init_mmc(void)
> > +{
> > + /* Expect somewhere already initialize MMC */
> > + return 0;
> > +}
> > +#endif
> [...]
>
next prev parent reply other threads:[~2018-02-22 8:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-05 7:06 [U-Boot] [PATCH v8 0/4] Generic firmware loader tien.fong.chee at intel.com
2018-02-05 7:06 ` [U-Boot] [PATCH v8 1/4] spl: Remove static declaration on spl_mmc_find_device function tien.fong.chee at intel.com
2018-02-15 14:58 ` Marek Vasut
2018-02-05 7:06 ` [U-Boot] [PATCH v8 2/4] cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount() tien.fong.chee at intel.com
2018-02-15 14:58 ` Marek Vasut
2018-02-05 7:06 ` [U-Boot] [PATCH v8 3/4] cmd: ubifs: Factor out some checking codes into cmd_ubifs_mount() tien.fong.chee at intel.com
2018-02-15 14:59 ` Marek Vasut
2018-02-22 6:04 ` Chee, Tien Fong
2018-02-05 7:06 ` [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system tien.fong.chee at intel.com
2018-02-15 14:58 ` Marek Vasut
2018-02-22 8:18 ` Chee, Tien Fong [this message]
2018-02-22 14:28 ` Marek Vasut
2018-02-22 15:50 ` Tom Rini
2018-02-26 6:22 ` Chee, Tien Fong
2018-02-26 6:20 ` Chee, Tien Fong
2018-02-22 9:02 ` Lothar Waßmann
2018-02-26 6:24 ` Chee, Tien Fong
2018-02-15 10:22 ` [U-Boot] [PATCH v8 0/4] Generic firmware loader Chee, Tien Fong
2018-02-15 10:28 ` 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=1519287480.9210.14.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.