From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH] SPL: FIT: Enable SPL_FIT_LOAD for sd bootmode for fat partions
Date: Mon, 2 May 2016 09:36:53 +0530 [thread overview]
Message-ID: <5726D25D.1030908@ti.com> (raw)
In-Reply-To: <b89a6d53dae934b3960c2d6fe764a282006063d9.1461835876.git.michal.simek@xilinx.com>
Hi Michal,
On Thursday 28 April 2016 03:01 PM, Michal Simek wrote:
> Support U-Boot SPL to load FIT image from fat partition.
> Fit image can be setup via CONFIG_SPL_FS_LOAD_KERNEL_NAME.
> Falcon mode is not supported.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> common/spl/spl_fat.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
> fs/fat/fat.c | 4 ++--
> 2 files changed, 46 insertions(+), 8 deletions(-)
>
> diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
> index d16cd540e38a..4e319c5fa470 100644
> --- a/common/spl/spl_fat.c
> +++ b/common/spl/spl_fat.c
> @@ -13,6 +13,7 @@
> #include <spl.h>
> #include <asm/u-boot.h>
> #include <fat.h>
> +#include <libfdt.h>
> #include <errno.h>
> #include <image.h>
>
> @@ -39,6 +40,29 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
> return err;
> }
>
> +#ifdef CONFIG_SPL_LOAD_FIT
> +static ulong spl_fat_file_read(struct spl_load_info *load, ulong sector,
> + ulong count, void *buf)
> +{
> + int err;
> + loff_t actread;
> + char *filename = (char *)load->priv;
> +
> + debug("%s: name %s, sector %lx, count %lx, buf %lx\n",
> + __func__, filename, sector, count, (ulong)buf);
> +
> + err = file_fat_read_at(filename, sector, buf, count, &actread);
> + if (err < 0) {
> + printf("%s: error reading image %s, err - %d\n",
> + __func__, filename, err);
> + return err;
> + }
> +
> + debug("actread %lx\n", (ulong)actread);
> + return actread;
> +}
> +#endif
> +
> int spl_load_image_fat(struct blk_desc *block_dev,
> int partition,
> const char *filename)
> @@ -57,16 +81,29 @@ int spl_load_image_fat(struct blk_desc *block_dev,
> if (err <= 0)
> goto end;
>
> - spl_parse_image_header(header);
> + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
> + image_get_magic(header) == FDT_MAGIC) {
> + struct spl_load_info load;
> +
> + debug("Found FIT\n");
> + load.priv = (char *)filename;
> + load.bl_len = 1;
> + load.read = spl_fat_file_read;
> + spl_load_simple_fit(&load, 0, header);
> + } else {
> + debug("Legacy image\n");
>
> - err = file_fat_read(filename, (u8 *)(uintptr_t)spl_image.load_addr, 0);
> + spl_parse_image_header(header);
>
> + err = file_fat_read(filename,
> + (u8 *)(uintptr_t)spl_image.load_addr, 0);
> end:
> #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
> - if (err <= 0)
> - printf("%s: error reading image %s, err - %d\n",
> - __func__, filename, err);
> + if (err <= 0)
> + printf("%s: error reading image %s, err - %d\n",
> + __func__, filename, err);
> #endif
> + }
>
> return (err <= 0);
> }
> @@ -81,6 +118,7 @@ int spl_load_image_fat_os(struct blk_desc *block_dev, int partition)
> if (err)
> return err;
>
> +#if !defined(CONFIG_SPL_LOAD_FIT)
> #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
> file = getenv("falcon_args_file");
> if (file) {
> @@ -116,7 +154,7 @@ defaults:
> #endif
> return -1;
> }
> -
> +#endif
> return spl_load_image_fat(block_dev, partition,
> CONFIG_SPL_FS_LOAD_KERNEL_NAME);
> }
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index 600a90e30922..0d987e0465ee 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -281,9 +281,9 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size)
>
> if ((unsigned long)buffer & (ARCH_DMA_MINALIGN - 1)) {
> ALLOC_CACHE_ALIGN_BUFFER(__u8, tmpbuf, mydata->sect_size);
> -
> +#if !defined(CONFIG_SPL_LOAD_FIT)
> printf("FAT: Misaligned buffer address (%p)\n", buffer);
> -
> +#endif
IMO, this is a hack. Why should fs worry about if it as fit image or
not. Also the read performance will be very slow if you do not pass the
aligned buffer address. I had a different approach[1] for this: first
copy the image to aligned buffer and then do a memcpy to the proper
destination(which showed a better performance). May be this is wrong.
Simon, which one do you prefer?
[1] http://patchwork.ozlabs.org/patch/610371/ (Still working on this :( )
Thanks and regards,
Lokesh
> while (size >= mydata->sect_size) {
> ret = disk_read(startsect++, 1, tmpbuf);
> if (ret != 1) {
>
next prev parent reply other threads:[~2016-05-02 4:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-28 9:31 [U-Boot] [RFC PATCH] SPL: FIT: Enable SPL_FIT_LOAD for sd bootmode for fat partions Michal Simek
2016-05-01 18:54 ` Simon Glass
2016-05-02 4:06 ` Lokesh Vutla [this message]
2016-05-02 7:57 ` Michal Simek
2016-05-03 9:10 ` Lokesh Vutla
2016-05-03 13:30 ` Michal Simek
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=5726D25D.1030908@ti.com \
--to=lokeshvutla@ti.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