diff mbox series

[U-Boot] spl: spi: Support full fitImage handling

Message ID 20180531155929.30953-1-marex@denx.de
State Accepted
Commit 26ad648ff4fcca2f5676a0690902be54a94f243d
Delegated to: Tom Rini
Headers show
Series [U-Boot] spl: spi: Support full fitImage handling | expand

Commit Message

Marek Vasut May 31, 2018, 3:59 p.m. UTC
Handle the case where the full fitImage support is enabled. In this
case, the whole fitImage must be loaded up front as some parts of the
fitImage code require memory-mapped access to the entire fitImage.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
---
 common/spl/spl_spi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Simon Glass June 7, 2018, 8:28 p.m. UTC | #1
Hi Marek,
On 31 May 2018 at 07:59, Marek Vasut <marex@denx.de> wrote:
> Handle the case where the full fitImage support is enabled. In this
> case, the whole fitImage must be loaded up front as some parts of the
> fitImage code require memory-mapped access to the entire fitImage.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  common/spl/spl_spi.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
> index df46046729..ba60a3a3c5 100644
> --- a/common/spl/spl_spi.c
> +++ b/common/spl/spl_spi.c
> @@ -110,8 +110,17 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
>                         return err;
>                 }
>
> -               if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
> -                       image_get_magic(header) == FDT_MAGIC) {
> +               if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
> +                   image_get_magic(header) == FDT_MAGIC) {
> +                       err = spi_flash_read(flash, payload_offs,
> +                                            roundup(fdt_totalsize(header), 4),
> +                                            (void *)CONFIG_SYS_LOAD_ADDR);

map_sysmem(CONFIG_SYS_LOAD_ADDR, fdt_totalsize(header))

otherwise your sandbox test won't work

> +                       if (err)
> +                               return err;
> +                       err = spl_parse_image_header(spl_image,
> +                                       (struct image_header *)CONFIG_SYS_LOAD_ADDR);

Same here

> +               } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
> +                          image_get_magic(header) == FDT_MAGIC) {
>                         struct spl_load_info load;
>
>                         debug("Found FIT\n");
> --
> 2.16.2
>

Regards,
Simon
Marek Vasut June 7, 2018, 8:55 p.m. UTC | #2
On 06/07/2018 10:28 PM, Simon Glass wrote:
> Hi Marek,
> On 31 May 2018 at 07:59, Marek Vasut <marex@denx.de> wrote:
>> Handle the case where the full fitImage support is enabled. In this
>> case, the whole fitImage must be loaded up front as some parts of the
>> fitImage code require memory-mapped access to the entire fitImage.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>>  common/spl/spl_spi.c | 13 +++++++++++--
>>  1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
>> index df46046729..ba60a3a3c5 100644
>> --- a/common/spl/spl_spi.c
>> +++ b/common/spl/spl_spi.c
>> @@ -110,8 +110,17 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
>>                         return err;
>>                 }
>>
>> -               if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
>> -                       image_get_magic(header) == FDT_MAGIC) {
>> +               if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
>> +                   image_get_magic(header) == FDT_MAGIC) {
>> +                       err = spi_flash_read(flash, payload_offs,
>> +                                            roundup(fdt_totalsize(header), 4),
>> +                                            (void *)CONFIG_SYS_LOAD_ADDR);
> 
> map_sysmem(CONFIG_SYS_LOAD_ADDR, fdt_totalsize(header))
> 
> otherwise your sandbox test won't work

Is this map_sysmem stuff explained anywhere ?
Simon Glass June 7, 2018, 9:05 p.m. UTC | #3
Hi Marek,

On 7 June 2018 at 12:55, Marek Vasut <marex@denx.de> wrote:
> On 06/07/2018 10:28 PM, Simon Glass wrote:
>> Hi Marek,
>> On 31 May 2018 at 07:59, Marek Vasut <marex@denx.de> wrote:
>>> Handle the case where the full fitImage support is enabled. In this
>>> case, the whole fitImage must be loaded up front as some parts of the
>>> fitImage code require memory-mapped access to the entire fitImage.
>>>
>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> ---
>>>  common/spl/spl_spi.c | 13 +++++++++++--
>>>  1 file changed, 11 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
>>> index df46046729..ba60a3a3c5 100644
>>> --- a/common/spl/spl_spi.c
>>> +++ b/common/spl/spl_spi.c
>>> @@ -110,8 +110,17 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
>>>                         return err;
>>>                 }
>>>
>>> -               if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
>>> -                       image_get_magic(header) == FDT_MAGIC) {
>>> +               if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
>>> +                   image_get_magic(header) == FDT_MAGIC) {
>>> +                       err = spi_flash_read(flash, payload_offs,
>>> +                                            roundup(fdt_totalsize(header), 4),
>>> +                                            (void *)CONFIG_SYS_LOAD_ADDR);
>>
>> map_sysmem(CONFIG_SYS_LOAD_ADDR, fdt_totalsize(header))
>>
>> otherwise your sandbox test won't work
>
> Is this map_sysmem stuff explained anywhere ?

Yes, see board/sandbox/README.sandbox

Regards,
Simon
Tom Rini July 11, 2018, 12:41 p.m. UTC | #4
On Thu, May 31, 2018 at 05:59:29PM +0200, Marek Vasut wrote:

> Handle the case where the full fitImage support is enabled. In this
> case, the whole fitImage must be loaded up front as some parts of the
> fitImage code require memory-mapped access to the entire fitImage.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index df46046729..ba60a3a3c5 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -110,8 +110,17 @@  static int spl_spi_load_image(struct spl_image_info *spl_image,
 			return err;
 		}
 
-		if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
-			image_get_magic(header) == FDT_MAGIC) {
+		if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
+		    image_get_magic(header) == FDT_MAGIC) {
+			err = spi_flash_read(flash, payload_offs,
+					     roundup(fdt_totalsize(header), 4),
+					     (void *)CONFIG_SYS_LOAD_ADDR);
+			if (err)
+				return err;
+			err = spl_parse_image_header(spl_image,
+					(struct image_header *)CONFIG_SYS_LOAD_ADDR);
+		} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+			   image_get_magic(header) == FDT_MAGIC) {
 			struct spl_load_info load;
 
 			debug("Found FIT\n");