[PATCH] drivers: clk: Adjust temp var data type to properly match that of struct clk_ops

2023-05-15 Thread Nathan Barrett-Morrison
In commit 5c5992cb90cf ("clk: Add debugging for return values"), a
temporary storage variable was added around the ops->get_rate() call
inside clk_get_rate(), so that the result could be passed through
log_ret.

This temporary variable was declared as an int, yet when we look in
struct clk_ops, we can see this needs to be a ulong:
ulong (*get_rate)(struct clk *clk);

This was resulting in a signed to unsigned casting error on our
builds, where a clock value of 0xABCDABCD was being incorrectly cast
to 0xABCDABCD.

Signed-off-by: Nathan Barrett-Morrison 
---
 drivers/clk/clk-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index dc3e9d6a26..4e3e3b8537 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -471,7 +471,7 @@ void clk_free(struct clk *clk)
 ulong clk_get_rate(struct clk *clk)
 {
const struct clk_ops *ops;
-   int ret;
+   ulong ret;
 
debug("%s(clk=%p)\n", __func__, clk);
if (!clk_valid(clk))
-- 
2.34.1



Re: spl: spi: Raw Kernel Image Support for Falcon Mode Boot Via SPI Devices

2022-04-20 Thread Nathan Barrett-Morrison
Hi Sean,

Unfortunately, I was testing this stuff out a few months ago and our
customer has moved on from using a raw kernel and is now using FIT.  I've
looked at your entire patchset more closely and agree that the last patch
you sent would be necessary as well.  It looks like that one *should *convert
SPL+SPI+Falcon into using your more generic spi_load() interface as well.

It's nice to see all of the SPL load interface being reworked.  I noticed a
ton of divergence between the various storage devices back when I was
looking at it.

If I get a chance, I will wrap back around and try your patchset, but it's
going to be awhile before our customer is enabling Falcon again I believe.

Sincerely,
Nathan

On Tue, Apr 19, 2022 at 6:03 PM Sean Anderson 
wrote:

> Hi Nathan,
>
> On 4/19/22 5:49 PM, Nathan Barrett-Morrison wrote:
> > [You don't often get email from nathan.morri...@timesys.com. Learn why
> this is important at http://aka.ms/LearnAboutSenderIdentification.]
> >
> > Hi Sean,
> >
> > Thanks for the response.  I don't have my embedded board I'm doing this
> on quite up to this version of U-Boot, but it does appear your patchset
> should resolve my issue in the future.  So please disregard my patch, I
> think we're good!
>
> Actually, I'm not sure it will resolve your issue, since you seem to be
> having issues
> with falcon boot, which I didn't modify. Can you try the following patch
> in addition
> to the ones I linked above? I haven't tested it at all, so ymmv.
>
> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
> index 037db1a19f..0ab8a10300 100644
> --- a/common/spl/spl_spi.c
> +++ b/common/spl/spl_spi.c
> @@ -18,41 +18,6 @@
>  #include 
>  #include 
>
> -#if CONFIG_IS_ENABLED(OS_BOOT)
> -/*
> - * Load the kernel, check for a valid header we can parse, and if found
> load
> - * the kernel and then device tree.
> - */
> -static int spi_load_image_os(struct spl_image_info *spl_image,
> -struct spl_boot_device *bootdev,
> -struct spi_flash *flash,
> -struct image_header *header)
> -{
> -   int err;
> -
> -   /* Read for a header, parse or error out. */
> -   spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
> -  (void *)header);
> -
> -   if (image_get_magic(header) != IH_MAGIC)
> -   return -1;
> -
> -   err = spl_parse_image_header(spl_image, bootdev, header);
> -   if (err)
> -   return err;
> -
> -   spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
> -  spl_image->size, (void *)spl_image->load_addr);
> -
> -   /* Read device tree. */
> -   spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
> -  CONFIG_SYS_SPI_ARGS_SIZE,
> -  (void *)CONFIG_SYS_SPL_ARGS_ADDR);
> -
> -   return 0;
> -}
> -#endif
> -
>  static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,
>   ulong count, void *buf)
>  {
> @@ -71,6 +36,29 @@ unsigned int __weak spl_spi_get_uboot_offs(struct
> spi_flash *flash)
> return CONFIG_SYS_SPI_U_BOOT_OFFS;
>  }
>
> +static int spi_do_load_image(struct spl_image_info *spl_image,
> +struct spl_boot_device *bootdev,
> +struct spl_load_info *load,
> +unsigned int payload_offs)
> +{
> +   int ret;
> +   struct image_header *header;
> +
> +   header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
> +
> +   /* mkimage header is 64 bytes. */
> +   ret = spi_flash_read(flash, payload_offs, sizeof(*header),
> +(void *)header);
> +   if (ret) {
> +   debug("%s: Failed to read from SPI flash (err=%d)\n",
> + __func__, ret);
> +   return ret;
> +   }
> +
> +   return spl_load(spl_image, bootdev, , header, 0,
> +   payload_offs);
> +}
> +
>  /*
>   * The main entry for SPI booting. It's necessary that SDRAM is already
>   * configured and available since this code loads the main U-Boot image
> @@ -82,7 +70,6 @@ static int spl_spi_load_image(struct spl_image_info
> *spl_image,
> int err = 0;
> unsigned int payload_offs;
> struct spi_flash *flash;
> -   struct image_header *header;
> struct spl_load_info load = {
> .bl_len = 1,
> .read = spl_spi_fit_read,
> @@ -106,31 +93,24 @@ static int spl_spi_load_image(struct spl_image_info
> *spl_image,
> 

Re: spl: spi: Raw Kernel Image Support for Falcon Mode Boot Via SPI Devices

2022-04-19 Thread Nathan Barrett-Morrison
Hi Sean,

Thanks for the response.  I don't have my embedded board I'm doing this on 
quite up to this version of U-Boot, but it does appear your patchset should 
resolve my issue in the future.  So please disregard my patch, I think we're 
good!

Sincerely,
Nathan

On 4/19/22 17:43, Sean Anderson wrote:
> Hi Nathan,
> 
> On 4/19/22 5:38 PM, Nathan Barrett-Morrison wrote:
>> [You don't often get email from nathan.morri...@timesys.com. Learn why this 
>> is important at http://aka.ms/LearnAboutSenderIdentification.]
>>
>> Hi Tom,
>>
>> I believe this patch is still relevant, so I'm resubmitting it.  It was 
>> previously marked as superseded.
>>
>> Thanks,
>> Nathan
>>
>> From 0bb98a42bcb01c078f63513d9151d307dbfd6ccd Mon Sep 17 00:00:00 2001
>> From: Nathan Barrett-Morrison 
>> Date: Tue, 19 Apr 2022 17:35:21 -0400
>> Subject: [PATCH v2] Allow Falcon Mode boot to use raw kernel image when 
>> booting
>>  via SPI.
>>
>> When using Falcon Mode boot with a raw, unwrapped kernel image, the 
>> bootz_setup() call inside of spl_parse_image_header() is
>> unreachable because the mkimage header magic check in spi_load_image_os() 
>> will never pass.  This check is entirely redundant and unnecessary,
>> as the spl_parse_image_header() call will also check for IH_MAGIC.
>>
>> Signed-off-by: Nathan Barrett-Morrison 
>> Cc: Tom Rini 
>> ---
>> Changes for v2:
>>- Remove proposed CONFIG_SYS_SPI_KERNEL_SKIP_HEADER option, as we've 
>> determined the entire check is redundant and unnecessary.  Just delete it 
>> instead.
>>
>>  common/spl/spl_spi.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
>> index cf3f7ef4c0..22e9c87eae 100644
>> --- a/common/spl/spl_spi.c
>> +++ b/common/spl/spl_spi.c
>> @@ -34,9 +34,6 @@ static int spi_load_image_os(struct spl_image_info 
>> *spl_image,
>> spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
>>(void *)header);
>>
>> -   if (image_get_magic(header) != IH_MAGIC)
>> -   return -1;
>> -
>> err = spl_parse_image_header(spl_image, bootdev, header);
>> if (err)
>> return err;
>> --
>> 2.30.2
>>
> 
> Can you see if [1] fixes your problem? You will also need the first patch in 
> the series.
> 
> --Sean
> 
> [1] 
> https://lore.kernel.org/u-boot/20220401190405.1932697-8-sean.ander...@seco.com/


spl: spi: Raw Kernel Image Support for Falcon Mode Boot Via SPI Devices

2022-04-19 Thread Nathan Barrett-Morrison
Hi Tom,

I believe this patch is still relevant, so I'm resubmitting it.  It was 
previously marked as superseded.

Thanks,
Nathan

>From 0bb98a42bcb01c078f63513d9151d307dbfd6ccd Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Tue, 19 Apr 2022 17:35:21 -0400
Subject: [PATCH v2] Allow Falcon Mode boot to use raw kernel image when booting
 via SPI.

When using Falcon Mode boot with a raw, unwrapped kernel image, the 
bootz_setup() call inside of spl_parse_image_header() is
unreachable because the mkimage header magic check in spi_load_image_os() will 
never pass.  This check is entirely redundant and unnecessary,
as the spl_parse_image_header() call will also check for IH_MAGIC.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
Changes for v2:
   - Remove proposed CONFIG_SYS_SPI_KERNEL_SKIP_HEADER option, as we've 
determined the entire check is redundant and unnecessary.  Just delete it 
instead.

 common/spl/spl_spi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index cf3f7ef4c0..22e9c87eae 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -34,9 +34,6 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
   (void *)header);
 
-   if (image_get_magic(header) != IH_MAGIC)
-   return -1;
-
err = spl_parse_image_header(spl_image, bootdev, header);
if (err)
return err;
-- 
2.30.2



Falcon Mode Support For Uncompressed Kernel Images

2022-04-19 Thread Nathan Barrett-Morrison
Hi Tom,

While trying to bring up Falcon Mode boot on an ARM64 board, I discovered
that there is no path which allows you to use an uncompressed kernel image
(booti).  I've added this path and attached the relevant patch.

Sincerely,
Nathan

>From f1c34333f79996bd2927a60f4858c01699431cba Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Wed, 2 Feb 2022 15:05:18 -0500
Subject: [PATCH v2] Add in the ability to load and boot an uncompressed kernel
 image during the Falcon Mode boot sequence.

This is required for architectures which do not support compressed kernel 
images (i.e. ARM64).  This is only used while not booting via FIT image.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
Changes for v2:
   - Remove original SPL_OS_BOOT_UNCOMPRESSED option and check via CMD_BOOTI 
and CMD_BOOTZ instead

 arch/arm/lib/Makefile |  5 -
 common/spl/spl.c  | 21 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c603fe61bc..08b7475e37 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -36,7 +36,10 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 else
 obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
-obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
+ifdef CONFIG_SPL_FRAMEWORK
+obj-$(CONFIG_CMD_BOOTI) += image.o
+obj-$(CONFIG_CMD_BOOTZ) += zimage.o
+endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
diff --git a/common/spl/spl.c b/common/spl/spl.c
index c9750ee163..7b86443f1b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -107,6 +107,11 @@ int __weak bootz_setup(ulong image, ulong *start, ulong 
*end)
 {
 return 1;
 }
+
+int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool 
force_reloc)
+{
+return 1;
+}
 #endif
 
 /* Weak default function for arch/board-specific fixups to the spl_image_info 
*/
@@ -366,6 +371,21 @@ int spl_parse_image_header(struct spl_image_info 
*spl_image,
 #endif
 
 #if CONFIG_IS_ENABLED(OS_BOOT)
+#if defined(CMD_BOOTI)
+   ulong start, size;
+
+   if (!booti_setup((ulong)header, , , 0)) {
+   spl_image->name = "Linux";
+   spl_image->os = IH_OS_LINUX;
+   spl_image->load_addr = start;
+   spl_image->entry_point = start;
+   spl_image->size = size;
+   debug(SPL_TPL_PROMPT
+ "payload Image, load addr: 0x%lx size: %d\n",
+ spl_image->load_addr, spl_image->size);
+   return 0;
+   }
+#elif defined(CMD_BOOTZ)
ulong start, end;
 
if (!bootz_setup((ulong)header, , )) {
@@ -379,6 +399,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
  spl_image->load_addr, spl_image->size);
return 0;
}
+#endif
 #endif
 
if (!spl_parse_board_header(spl_image, bootdev, (const void 
*)header, sizeof(*header)))
-- 
2.30.2



drivers: mtd: spi: Allow Quad I/O enablement for ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

2022-04-19 Thread Nathan Barrett-Morrison
Hi All,

I noticed this was missing from the spi-nor-tiny.c subsystem while trying to 
use an ISSI SPI flash device with the U-Boot SPL.

This patch will allow Quad (4x) I/O mode to be enabled with ISSI flash devices 
while inside the U-Boot SPL / using spi-nor-tiny.c.

Sincerely,
Nathan

>From 1a7fd52f21d3d3ad4b2ff736a9ea3c1affb9c007 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Wed, 26 Jan 2022 13:44:39 -0500
Subject: [PATCH] drivers: mtd: spi: Allow Quad I/O enablement for ISSI SPI
 flash devices alongside spi-nor-tiny.c subsystem

Signed-off-by: Nathan Barrett-Morrison 
Cc: Jagan Teki 
Cc: Vignesh R 
CC: Tom Rini 
---
 drivers/mtd/spi/spi-nor-tiny.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index 130917aaa8..4957448d11 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -664,6 +664,7 @@ static int spi_nor_setup(struct spi_nor *nor, const struct 
flash_info *info,
switch (JEDEC_MFR(info)) {
 #ifdef CONFIG_SPI_FLASH_MACRONIX
case SNOR_MFR_MACRONIX:
+   case SNOR_MFR_ISSI:
err = macronix_quad_enable(nor);
break;
 #endif
-- 
2.34.1



drivers: mtd: spi: Use correct 4 byte mode enablement for ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

2022-04-19 Thread Nathan Barrett-Morrison
Hi All,

I noticed this was missing from the spi-nor-tiny.c subsystem while trying to 
use an ISSI SPI flash device with the U-Boot SPL.

This patch will allow 4 byte addressing mode to be enabled with ISSI flash 
devices while inside the U-Boot SPL / using spi-nor-tiny.c.

Sincerely,
Nathan

>From 218e00fcaea8c5795e792af09f5d21fc19e3d831 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Wed, 26 Jan 2022 13:43:53 -0500
Subject: [PATCH] drivers: mtd: spi: Use correct 4 byte mode enablement for
 ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

Signed-off-by: Nathan Barrett-Morrison 
Cc: Jagan Teki 
Cc: Vignesh R 
CC: Tom Rini 
---
 drivers/mtd/spi/spi-nor-tiny.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index 68152ce3b4..130917aaa8 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -219,6 +219,7 @@ static inline int set_4byte(struct spi_nor *nor, const 
struct flash_info *info,
case SNOR_MFR_MICRON:
/* Some Micron need WREN command; all will accept it */
need_wren = true;
+   case SNOR_MFR_ISSI:
case SNOR_MFR_MACRONIX:
case SNOR_MFR_WINBOND:
if (need_wren)
-- 
2.34.1




Re: Falcon Mode Support For Uncompressed Kernel Images

2022-04-19 Thread Nathan Barrett-Morrison
One more time --

>From f1c34333f79996bd2927a60f4858c01699431cba Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Wed, 2 Feb 2022 15:05:18 -0500
Subject: [PATCH v2] Add in the ability to load and boot an uncompressed kernel
 image during the Falcon Mode boot sequence.

This is required for architectures which do not support compressed kernel 
images (i.e. ARM64).  This is only used while not booting via FIT image.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
Changes for v2:
   - Remove original SPL_OS_BOOT_UNCOMPRESSED option and check via CMD_BOOTI 
and CMD_BOOTZ instead

 arch/arm/lib/Makefile |  5 -
 common/spl/spl.c  | 21 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c603fe61bc..08b7475e37 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -36,7 +36,10 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 else
 obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
-obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
+ifdef CONFIG_SPL_FRAMEWORK
+obj-$(CONFIG_CMD_BOOTI) += image.o
+obj-$(CONFIG_CMD_BOOTZ) += zimage.o
+endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
diff --git a/common/spl/spl.c b/common/spl/spl.c
index c9750ee163..7b86443f1b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -107,6 +107,11 @@ int __weak bootz_setup(ulong image, ulong *start, ulong 
*end)
 {
 return 1;
 }
+
+int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool 
force_reloc)
+{
+return 1;
+}
 #endif
 
 /* Weak default function for arch/board-specific fixups to the spl_image_info 
*/
@@ -366,6 +371,21 @@ int spl_parse_image_header(struct spl_image_info 
*spl_image,
 #endif
 
 #if CONFIG_IS_ENABLED(OS_BOOT)
+#if defined(CMD_BOOTI)
+   ulong start, size;
+
+   if (!booti_setup((ulong)header, , , 0)) {
+   spl_image->name = "Linux";
+   spl_image->os = IH_OS_LINUX;
+   spl_image->load_addr = start;
+   spl_image->entry_point = start;
+   spl_image->size = size;
+   debug(SPL_TPL_PROMPT
+ "payload Image, load addr: 0x%lx size: %d\n",
+ spl_image->load_addr, spl_image->size);
+   return 0;
+   }
+#elif defined(CMD_BOOTZ)
ulong start, end;
 
if (!bootz_setup((ulong)header, , )) {
@@ -379,6 +399,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
  spl_image->load_addr, spl_image->size);
return 0;
}
+#endif
 #endif
 
if (!spl_parse_board_header(spl_image, bootdev, (const void 
*)header, sizeof(*header)))
-- 
2.30.2



On 4/19/22 17:16, Nathan Barrett-Morrison wrote:
> Hi Tom,
> 
> Let's see if this works any better.  Using a new mail client that is supposed 
> to not modify whitespace:
> 
> From f1c34333f79996bd2927a60f4858c01699431cba Mon Sep 17 00:00:00 2001
> From: Nathan Barrett Morrison 
> Date: Wed, 2 Feb 2022 15:05:18 -0500
> Subject: [PATCH v2] Add in the ability to load and boot an uncompressed kernel
>  image during the Falcon Mode boot sequence.
> 
> This is required for architectures which do not support compressed kernel 
> images (i.e. ARM64).  This is only used while not booting via FIT image.
> 
> Signed-off-by: Nathan Barrett-Morrison 
> Cc: Tom Rini 
> ---
> Changes for v2:
>- Remove original SPL_OS_BOOT_UNCOMPRESSED option and check via CMD_BOOTI 
> and CMD_BOOTZ instead
> 
>  arch/arm/lib/Makefile |  5 -
>  common/spl/spl.c  | 21 +
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> index c603fe61bc..08b7475e37 100644
> --- a/arch/arm/lib/Makefile
> +++ b/arch/arm/lib/Makefile
> @@ -36,7 +36,10 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
>  obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
>  else
>  obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
> -obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
> +ifdef CONFIG_SPL_FRAMEWORK
> +obj-$(CONFIG_CMD_BOOTI) += image.o
> +obj-$(CONFIG_CMD_BOOTZ) += zimage.o
> +endif
>  obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
>  endif
>  ifdef CONFIG_ARM64
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index c9750ee163..7b86443f1b 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -107,6 +107,11 @@ int __weak bootz_setup(ulong image, ulong *start, ulong 
> *end)
>  {
>return 1;
>  }
> +
> +int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool 
> force_reloc)
> +

Re: Falcon Mode Support For Uncompressed Kernel Images

2022-04-19 Thread Nathan Barrett-Morrison
Hi Tom,

Let's see if this works any better.  Using a new mail client that is supposed 
to not modify whitespace:

>From f1c34333f79996bd2927a60f4858c01699431cba Mon Sep 17 00:00:00 2001
From: Nathan Barrett Morrison 
Date: Wed, 2 Feb 2022 15:05:18 -0500
Subject: [PATCH v2] Add in the ability to load and boot an uncompressed kernel
 image during the Falcon Mode boot sequence.

This is required for architectures which do not support compressed kernel 
images (i.e. ARM64).  This is only used while not booting via FIT image.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
Changes for v2:
   - Remove original SPL_OS_BOOT_UNCOMPRESSED option and check via CMD_BOOTI 
and CMD_BOOTZ instead

 arch/arm/lib/Makefile |  5 -
 common/spl/spl.c  | 21 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c603fe61bc..08b7475e37 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -36,7 +36,10 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 else
 obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
-obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
+ifdef CONFIG_SPL_FRAMEWORK
+obj-$(CONFIG_CMD_BOOTI) += image.o
+obj-$(CONFIG_CMD_BOOTZ) += zimage.o
+endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
diff --git a/common/spl/spl.c b/common/spl/spl.c
index c9750ee163..7b86443f1b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -107,6 +107,11 @@ int __weak bootz_setup(ulong image, ulong *start, ulong 
*end)
 {
 return 1;
 }
+
+int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool 
force_reloc)
+{
+return 1;
+}
 #endif
 
 /* Weak default function for arch/board-specific fixups to the spl_image_info 
*/
@@ -366,6 +371,21 @@ int spl_parse_image_header(struct spl_image_info 
*spl_image,
 #endif
 
 #if CONFIG_IS_ENABLED(OS_BOOT)
+#if defined(CMD_BOOTI)
+   ulong start, size;
+
+   if (!booti_setup((ulong)header, , , 0)) {
+   spl_image->name = "Linux";
+   spl_image->os = IH_OS_LINUX;
+   spl_image->load_addr = start;
+   spl_image->entry_point = start;
+   spl_image->size = size;
+   debug(SPL_TPL_PROMPT
+ "payload Image, load addr: 0x%lx size: %d\n",
+ spl_image->load_addr, spl_image->size);
+   return 0;
+   }
+#elif defined(CMD_BOOTZ)
ulong start, end;
 
if (!bootz_setup((ulong)header, , )) {
@@ -379,6 +399,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
  spl_image->load_addr, spl_image->size);
return 0;
}
+#endif
 #endif
 
if (!spl_parse_board_header(spl_image, bootdev, (const void 
*)header, sizeof(*header)))
-- 
2.30.2

On 4/19/22 16:30, Tom Rini wrote:
> On Wed, Feb 02, 2022 at 04:53:11PM -0500, Nathan Barrett-Morrison wrote:
>> Hi Tom,
>>
>> I've attached version 2 of the patch.  I believe this should adhere more
>> closely to your suggestions.
>>
>> Keep in mind, CONFIG_IS_ENABLED will not work for checking
>> CMD_BOOTI/CMD_BOOTZ in this case, as there is no CONFIG_SPL_CMD_BOOTx.  So,
>> I'm just directly checking if it's defined instead.
>>
>> I verified both CONFIG_IS_ENABLED() and IS_ENABLED() did not work.
>>
>> Sincerely,
>> Nathan
>>
>> On Mon, Jan 31, 2022 at 10:35 AM Tom Rini  wrote:
>>
>>> On Mon, Jan 31, 2022 at 10:23:58AM -0500, Nathan Barrett-Morrison wrote:
>>>
>>>> Hi Tom,
>>>>
>>>> Yea, I'm not sure if uncompressed ARM32 would work, but I don't believe
>>> it
>>>> was ever working to begin with... as bootz_setup is being called right
>>> now
>>>> ( @
>>> https://source.denx.de/u-boot/u-boot/-/blob/master/common/spl/spl.c#L366
>>>> )
>>>>
>>>> My intent was for SPL_OS_BOOT_UNCOMPRESSED to only be used for platforms
>>>> which need booti_setup (ARM64, ...).
>>>>
>>>> So... I could add a dependency on ARM64 in the config option or I could
>>>> remove the option altogether and let the booti_setup fail and fallback to
>>>> bootz_setup.  Would either of those work for you?
>>>
>>> The code and logic overall needs a bit of refactoring to support
>>> "booti", "bootz" and also FIT images.  I believe FIT images are how
>>> anyone doing falcon mode on arm64 has worked thus far.  booti/bootz
>>> should only be an option when CMD_BOOTI/Z i

[PATCH] common: spl: spl_mmc: Add full FIT image support for kernel/OS loading during Falcon boot mode while booting via MMC

2022-02-08 Thread Nathan Barrett-Morrison
Hi Tom,

This patch adds support for Falcon mode boot via MMC flash boot devices
with full FIT images.

While attempting to use Falcon boot mode with FIT images on MMC flash boot
devices, I've found the following additional code to be required.

Patch attached and also added inline below:

Sincerely,
Nathan

>From a3d066656df60856950c9cbb28914d02d57c9364 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Tue, 8 Feb 2022 13:16:24 -0500
Subject: [PATCH] common: spl: spl_mmc: Add full FIT image support for
 kernel/OS loading during Falcon boot mode while booting via MMC

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
 common/spl/spl_mmc.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index e1a7d25bd0..7fb2505c33 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -94,7 +94,19 @@ int mmc_load_image_raw_sector(struct spl_image_info
*spl_image,
  goto end;
  }

- if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
+image_get_magic(header) == FDT_MAGIC) {
+ u32 image_size_sectors;
+
+ debug("Found FIT\n");
+
+ image_size_sectors = (roundup(fdt_totalsize(header), 4) +
mmc->read_bl_len - 1) /
+ mmc->read_bl_len;
+ count = blk_dread(bd, sector, image_size_sectors, CONFIG_SYS_LOAD_ADDR);
+ debug("hdr read sector %lx, count=%lu\n", sector, count);
+
+ ret = spl_parse_image_header(spl_image, CONFIG_SYS_LOAD_ADDR);
+ } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
 image_get_magic(header) == FDT_MAGIC) {
  struct spl_load_info load;

-- 
2.30.2
From a3d066656df60856950c9cbb28914d02d57c9364 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Tue, 8 Feb 2022 13:16:24 -0500
Subject: [PATCH] common: spl: spl_mmc: Add full FIT image support for
 kernel/OS loading during Falcon boot mode while booting via MMC

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
 common/spl/spl_mmc.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index e1a7d25bd0..7fb2505c33 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -94,7 +94,19 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
 		goto end;
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
+	image_get_magic(header) == FDT_MAGIC) {
+		u32 image_size_sectors;
+
+		debug("Found FIT\n");
+
+		image_size_sectors = (roundup(fdt_totalsize(header), 4) + mmc->read_bl_len - 1) /
+ mmc->read_bl_len;
+		count = blk_dread(bd, sector, image_size_sectors, CONFIG_SYS_LOAD_ADDR);
+		debug("hdr read sector %lx, count=%lu\n", sector, count);
+
+		ret = spl_parse_image_header(spl_image, CONFIG_SYS_LOAD_ADDR);
+	} else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
 	image_get_magic(header) == FDT_MAGIC) {
 		struct spl_load_info load;
 
-- 
2.30.2



[PATCH] common: spl: spl_spi: Add in FIT image support for kernel/OS loading during Falcon boot mode while booting via SPI

2022-02-08 Thread Nathan Barrett-Morrison
Hi Tom,

This patch adds support for Falcon mode boot via SPI flash boot devices
with FIT images.

While attempting to use Falcon boot mode with FIT images on SPI flash boot
devices, I've found the following additional code to be required.

Patch attached and also added inline below:

Sincerely,
Nathan

>From b93c9122114ee701f13a62af63d74a0644fcef92 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Tue, 8 Feb 2022 13:05:34 -0500
Subject: [PATCH] common: spl: spl_spi: Add in FIT image support for
kernel/OS
 loading during Falcon boot mode while booting via SPI

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
 common/spl/spl_spi.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 4e20a23dea..82b396fc62 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -29,6 +29,18 @@ static int spi_load_image_os(struct spl_image_info
*spl_image,
 {
  int err;

+#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) || CONFIG_IS_ENABLED(LOAD_FIT)
+ spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(struct
fdt_header),
+   (void *)header);
+
+ if (image_get_magic(header) == FDT_MAGIC)
+ spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
+   roundup(fdt_totalsize(header), 4), CONFIG_SYS_LOAD_ADDR);
+
+ err = spl_parse_image_header(spl_image, CONFIG_SYS_LOAD_ADDR);
+ if (err)
+ return err;
+#else
  /* Read for a header, parse or error out. */
  spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
(void *)header);
@@ -47,6 +59,7 @@ static int spi_load_image_os(struct spl_image_info
*spl_image,
  spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
CONFIG_SYS_SPI_ARGS_SIZE,
(void *)CONFIG_SYS_SPL_ARGS_ADDR);
+#endif

  return 0;
 }
-- 
2.30.2
From b93c9122114ee701f13a62af63d74a0644fcef92 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Tue, 8 Feb 2022 13:05:34 -0500
Subject: [PATCH] common: spl: spl_spi: Add in FIT image support for kernel/OS
 loading during Falcon boot mode while booting via SPI

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
 common/spl/spl_spi.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 4e20a23dea..82b396fc62 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -29,6 +29,18 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
 {
 	int err;
 
+#if CONFIG_IS_ENABLED(LOAD_FIT_FULL) || CONFIG_IS_ENABLED(LOAD_FIT)
+	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(struct fdt_header),
+		   (void *)header);
+
+	if (image_get_magic(header) == FDT_MAGIC)
+		spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
+		   roundup(fdt_totalsize(header), 4), CONFIG_SYS_LOAD_ADDR);
+
+	err = spl_parse_image_header(spl_image, CONFIG_SYS_LOAD_ADDR);
+	if (err)
+		return err;
+#else
 	/* Read for a header, parse or error out. */
 	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
 		   (void *)header);
@@ -47,6 +59,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
 	spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
 		   CONFIG_SYS_SPI_ARGS_SIZE,
 		   (void *)CONFIG_SYS_SPL_ARGS_ADDR);
+#endif
 
 	return 0;
 }
-- 
2.30.2



Re: Raw Kernel Image Support for Falcon Mode Boot Via SPI Devices

2022-02-02 Thread Nathan Barrett-Morrison
Hi Tom,

I've attached v2 of this patch.  I've also confirmed again that the
offending lines are entirely unnecessary and amended the patch to delete
them instead.

Sincerely,
Nathan

On Mon, Jan 31, 2022 at 10:23 AM Tom Rini  wrote:

> On Mon, Jan 31, 2022 at 10:16:08AM -0500, Nathan Barrett-Morrison wrote:
>
> > Hi Tom,
> >
> > Yes -- I believe this section of code should not be checking for IH_MAGIC
> > at all, as parse_image_header does it as well.
> >
> > Would you like me to resubmit this patch with the offending lines
> deleted?
>
> Well, please take a good look over the whole area of code and see if it
> really makes sense to do what it's doing there or not.
>
> --
> Tom
>
From 65e75debf7813760bf192b477818093e35909081 Mon Sep 17 00:00:00 2001
From: Nathan Barrett Morrison 
Date: Wed, 2 Feb 2022 16:56:50 -0500
Subject: [PATCH v2] Allow Falcon Mode boot to use raw kernel image when booting
 via SPI.

When using Falcon Mode boot with a raw, unwrapped kernel image, the bootz_setup() call inside of spl_parse_image_header() is
unreachable because the mkimage header magic check in spi_load_image_os() will never pass.  This check is entirely redundant and unnecessary,
as the spl_parse_image_header() call will also check for IH_MAGIC.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
Changes for v2:
   - Remove proposed CONFIG_SYS_SPI_KERNEL_SKIP_HEADER option, as we've determined the entire check is redundant and unnecessary.  Just delete it instead.

 common/spl/spl_spi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 4e20a23dea..16e268be50 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -33,9 +33,6 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
 	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
 		   (void *)header);
 
-	if (image_get_magic(header) != IH_MAGIC)
-		return -1;
-
 	err = spl_parse_image_header(spl_image, header);
 	if (err)
 		return err;
-- 
2.30.2



Re: Falcon Mode Support For Uncompressed Kernel Images

2022-02-02 Thread Nathan Barrett-Morrison
Hi Tom,

I've attached version 2 of the patch.  I believe this should adhere more
closely to your suggestions.

Keep in mind, CONFIG_IS_ENABLED will not work for checking
CMD_BOOTI/CMD_BOOTZ in this case, as there is no CONFIG_SPL_CMD_BOOTx.  So,
I'm just directly checking if it's defined instead.

I verified both CONFIG_IS_ENABLED() and IS_ENABLED() did not work.

Sincerely,
Nathan

On Mon, Jan 31, 2022 at 10:35 AM Tom Rini  wrote:

> On Mon, Jan 31, 2022 at 10:23:58AM -0500, Nathan Barrett-Morrison wrote:
>
> > Hi Tom,
> >
> > Yea, I'm not sure if uncompressed ARM32 would work, but I don't believe
> it
> > was ever working to begin with... as bootz_setup is being called right
> now
> > ( @
> https://source.denx.de/u-boot/u-boot/-/blob/master/common/spl/spl.c#L366
> > )
> >
> > My intent was for SPL_OS_BOOT_UNCOMPRESSED to only be used for platforms
> > which need booti_setup (ARM64, ...).
> >
> > So... I could add a dependency on ARM64 in the config option or I could
> > remove the option altogether and let the booti_setup fail and fallback to
> > bootz_setup.  Would either of those work for you?
>
> The code and logic overall needs a bit of refactoring to support
> "booti", "bootz" and also FIT images.  I believe FIT images are how
> anyone doing falcon mode on arm64 has worked thus far.  booti/bootz
> should only be an option when CMD_BOOTI/Z is set, and FIT should depend
> on SPL_LOAD_FIT already.
>
> --
> Tom
>
From 5d37f2a930e7cb3455b6ec925ec6e67b40d4c022 Mon Sep 17 00:00:00 2001
From: Nathan Barrett Morrison 
Date: Wed, 2 Feb 2022 15:05:18 -0500
Subject: [PATCH v2] Add in the ability to load and boot an uncompressed kernel
 image during the Falcon Mode boot sequence.

This is required for architectures which do not support compressed kernel images (i.e. ARM64).  This is only used while not booting via FIT image.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
---
Changes for v2:
   - Remove original SPL_OS_BOOT_UNCOMPRESSED option and check via CMD_BOOTI and CMD_BOOTZ instead

 arch/arm/lib/Makefile |  5 -
 common/spl/spl.c  | 21 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c48e1f622d..57e49f69f7 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -36,7 +36,10 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 else
 obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
-obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
+ifdef CONFIG_SPL_FRAMEWORK
+obj-$(CONFIG_CMD_BOOTI) += image.o
+obj-$(CONFIG_CMD_BOOTZ) += zimage.o
+endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
diff --git a/common/spl/spl.c b/common/spl/spl.c
index f51d1f3205..1f6b3f1ac8 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -104,6 +104,11 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
 {
 	 return 1;
 }
+
+int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc)
+{
+	 return 1;
+}
 #endif
 
 /* Weak default function for arch/board-specific fixups to the spl_image_info */
@@ -354,6 +359,21 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 #endif
 
 #if CONFIG_IS_ENABLED(OS_BOOT)
+#if defined(CMD_BOOTI)
+		ulong start, size;
+
+		if (!booti_setup((ulong)header, , , 0)) {
+			spl_image->name = "Linux";
+			spl_image->os = IH_OS_LINUX;
+			spl_image->load_addr = start;
+			spl_image->entry_point = start;
+			spl_image->size = size;
+			debug(SPL_TPL_PROMPT
+			  "payload Image, load addr: 0x%lx size: %d\n",
+			  spl_image->load_addr, spl_image->size);
+			return 0;
+		}
+#elif defined(CMD_BOOTZ)
 		ulong start, end;
 
 		if (!bootz_setup((ulong)header, , )) {
@@ -367,6 +387,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 			  spl_image->load_addr, spl_image->size);
 			return 0;
 		}
+#endif
 #endif
 
 		if (!spl_parse_board_header(spl_image, (const void *)header, sizeof(*header)))
-- 
2.30.2



Re: Falcon Mode Support For Uncompressed Kernel Images

2022-01-31 Thread Nathan Barrett-Morrison
Hi Tom,

Yea, I'm not sure if uncompressed ARM32 would work, but I don't believe it
was ever working to begin with... as bootz_setup is being called right now
( @ https://source.denx.de/u-boot/u-boot/-/blob/master/common/spl/spl.c#L366
)

My intent was for SPL_OS_BOOT_UNCOMPRESSED to only be used for platforms
which need booti_setup (ARM64, ...).

So... I could add a dependency on ARM64 in the config option or I could
remove the option altogether and let the booti_setup fail and fallback to
bootz_setup.  Would either of those work for you?

Sincerely,
Nathan

On Mon, Jan 31, 2022 at 10:11 AM Tom Rini  wrote:

> On Mon, Jan 17, 2022 at 07:58:00PM -0500, Nathan Barrett-Morrison wrote:
> > Hi All,
> >
> > While trying to bring up Falcon Mode boot on an ARM64 board, I discovered
> > that there is no path which allows you to use an uncompressed kernel
> image
> > (booti).  I've added this path and attached the relevant patch.
> >
> > I've made this a separate if/else CONFIG option instead of allowing both
> > bootz+booti paths to coexist, as it seems unlikely to me that there would
> > be such a board which needs both.  Most architectures use either bootz or
> > booti, but not both.
> >
> > Sincerely,
> > Nathan Barrett-Morrison
>
> > From d5542ccc2d4f81ac0442be8ca772a99e1a13b6dd Mon Sep 17 00:00:00 2001
> > From: Nathan Barrett-Morrison 
> > Date: Mon, 17 Jan 2022 19:42:10 -0500
> > Subject: [PATCH] Add in the ability to load and boot an uncompressed
> >  kernel image during the Falcon Mode boot sequence.  This is required for
> >  architectures which do not support compressed kernel image booting
> (i.e.,
> >  ARM64)
> >
> > Signed-off-by: Nathan Barrett-Morrison 
> > Cc: Tom Rini 
> > Cc: Aneesh V 
> > ---
> >  arch/arm/lib/Makefile |  2 +-
> >  common/spl/Kconfig|  6 ++
> >  common/spl/spl.c  | 21 +
> >  3 files changed, 28 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> > index c48e1f622d..24c9e3c1e5 100644
> > --- a/arch/arm/lib/Makefile
> > +++ b/arch/arm/lib/Makefile
> > @@ -36,7 +36,7 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
> >  obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
> >  else
> >  obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
> > -obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
> > +obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o image.o
> >  obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
> >  endif
> >  ifdef CONFIG_ARM64
> > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > index 4a739a7421..6d2c9f 100644
> > --- a/common/spl/Kconfig
> > +++ b/common/spl/Kconfig
> > @@ -917,6 +917,12 @@ config SYS_OS_BASE
> > Specify the address, where the OS image is found, which
> > gets booted.
> >
> > +config SPL_OS_BOOT_UNCOMPRESSED
> > + bool "Use uncompressed kernel image alongside Falcon Mode"
> > + depends on SPL_SPI_LOAD
> > + help
> > +   Use an uncompressed kernel image to boot.  This is targetting
> > +   architectures which use booti instead of bootz (i.e, ARM64).
> >  endif # SPL_OS_BOOT
>
> We shouldn't need another CONFIG option here, and this would then I
> believe fail to boot uncompressed arm32 images.  The real problem I
> think is that the code assumed bootm/bootz but needs to instead be more
> explicit in checking / supporting each and then also yes, adding booti
> support.  Following up with also supporting compressed Images may or may
> not take additional logic, I'm not sure off-hand.
>
> --
> Tom
>


Re: Raw Kernel Image Support for Falcon Mode Boot Via SPI Devices

2022-01-31 Thread Nathan Barrett-Morrison
Hi Tom,

Yes -- I believe this section of code should not be checking for IH_MAGIC
at all, as parse_image_header does it as well.

Would you like me to resubmit this patch with the offending lines deleted?

Sincerely,
Nathan

On Mon, Jan 31, 2022 at 10:14 AM Tom Rini  wrote:

> On Mon, Jan 17, 2022 at 08:02:58PM -0500, Nathan Barrett-Morrison wrote:
>
> > Hi All,
> >
> > While trying to bring up Falcon Mode boot on an ARM64 board, I've
> > discovered that the SPL+SPI(spl_spi.c) driver does not allow us to load a
> > raw kernel image and subsequently call the bootz_setup() function which
> > resides in spl_parse_image_header().
> >
> > I've added a new config option (CONFIG_SYS_SPI_KERNEL_SKIP_HEADER) which
> > will skip the mkimage header check, allowing the subsequent
> > spl_parse_image_header() call to successfully fall through to
> bootz_setup()
> > and load/boot a raw kernel image.
> >
> > Sincerely,
> > Nathan Barrett-Morrison
>
> > From e5a15a8ad2fd007e6d8d48dd64767d194bbd1833 Mon Sep 17 00:00:00 2001
> > From: Nathan Barrett-Morrison 
> > Date: Mon, 17 Jan 2022 19:42:59 -0500
> > Subject: [PATCH] Allow Falcon Mode boot to use raw kernel image when
> >  booting via SPI.  When using Falcon Mode boot with a raw, unwrapped
> kernel
> >  image, the bootz_setup() call inside of spl_parse_image_header() is
> >  unreachable because the mkimage header magic check will never pass.
> Adding
> >  CONFIG_SYS_SPI_KERNEL_SKIP_HEADER gives us the ability to pass through
> to the
> >  desired bootz_setup() call.
> >
> > Signed-off-by: Nathan Barrett-Morrison 
> > Cc: Tom Rini 
> > Cc: Aneesh V 
> > ---
> >  common/spl/spl_spi.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
> > index 4e20a23dea..62dad1d2fb 100644
> > --- a/common/spl/spl_spi.c
> > +++ b/common/spl/spl_spi.c
> > @@ -33,8 +33,10 @@ static int spi_load_image_os(struct spl_image_info
> *spl_image,
> >   spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
> >  (void *)header);
> >
> > +#ifndef CONFIG_SYS_SPI_KERNEL_SKIP_HEADER
> >   if (image_get_magic(header) != IH_MAGIC)
> >   return -1;
> > +#endif
> >
> >   err = spl_parse_image_header(spl_image, header);
> >   if (err)
>
> I'm not sure this is the right path.  Why is this part of the code
> checking for IH_MAGIC at all, and should it not instead allow for
> graceful falling back so that zImage/Image/etc work?
>
> --
> Tom
>


drivers: mtd: spi: Use correct 4 byte mode enablement for ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

2022-01-26 Thread Nathan Barrett-Morrison
Hi All,

I noticed this was missing from the spi-nor-tiny.c subsystem while trying
to use an ISSI SPI flash device with the U-Boot SPL.

This patch will allow 4 byte addressing mode to be enabled with ISSI flash
devices while inside the U-Boot SPL / using spi-nor-tiny.c.

Sincerely,
Nathan
From 218e00fcaea8c5795e792af09f5d21fc19e3d831 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Wed, 26 Jan 2022 13:43:53 -0500
Subject: [PATCH] drivers: mtd: spi: Use correct 4 byte mode enablement for
 ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

Signed-off-by: Nathan Barrett-Morrison 
Cc: Jagan Teki 
Cc: Vignesh R 
CC: Tom Rini 
---
 drivers/mtd/spi/spi-nor-tiny.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index 68152ce3b4..130917aaa8 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -219,6 +219,7 @@ static inline int set_4byte(struct spi_nor *nor, const struct flash_info *info,
 	case SNOR_MFR_MICRON:
 		/* Some Micron need WREN command; all will accept it */
 		need_wren = true;
+	case SNOR_MFR_ISSI:
 	case SNOR_MFR_MACRONIX:
 	case SNOR_MFR_WINBOND:
 		if (need_wren)
-- 
2.34.1



[PATCH] drivers: mtd: spi: Use correct 4 byte mode enablement for ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

2022-01-26 Thread Nathan Barrett-Morrison
Hi All,

I noticed this was missing from the spi-nor-tiny.c subsystem while trying
to use an ISSI SPI flash device with the U-Boot SPL.

This patch will allow 4 byte addressing mode to be enabled with ISSI flash
devices while inside the U-Boot SPL / using spi-nor-tiny.c.

Sincerely,
Nathan


drivers: mtd: spi: Allow Quad I/O enablement for ISSI SPI flash devices alongside spi-nor-tiny.c subsystem

2022-01-26 Thread Nathan Barrett-Morrison
Hi All,

I noticed this was missing from the spi-nor-tiny.c subsystem while trying
to use an ISSI SPI flash device with the U-Boot SPL.

This patch will allow Quad (4x) I/O mode to be enabled with ISSI flash
devices while inside the U-Boot SPL / using spi-nor-tiny.c.

Sincerely,
Nathan
From 1a7fd52f21d3d3ad4b2ff736a9ea3c1affb9c007 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Wed, 26 Jan 2022 13:44:39 -0500
Subject: [PATCH] drivers: mtd: spi: Allow Quad I/O enablement for ISSI SPI
 flash devices alongside spi-nor-tiny.c subsystem

Signed-off-by: Nathan Barrett-Morrison 
Cc: Jagan Teki 
Cc: Vignesh R 
CC: Tom Rini 
---
 drivers/mtd/spi/spi-nor-tiny.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index 130917aaa8..4957448d11 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -664,6 +664,7 @@ static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
 		switch (JEDEC_MFR(info)) {
 #ifdef CONFIG_SPI_FLASH_MACRONIX
 		case SNOR_MFR_MACRONIX:
+		case SNOR_MFR_ISSI:
 			err = macronix_quad_enable(nor);
 			break;
 #endif
-- 
2.34.1



Raw Kernel Image Support for Falcon Mode Boot Via SPI Devices

2022-01-17 Thread Nathan Barrett-Morrison
Hi All,

While trying to bring up Falcon Mode boot on an ARM64 board, I've
discovered that the SPL+SPI(spl_spi.c) driver does not allow us to load a
raw kernel image and subsequently call the bootz_setup() function which
resides in spl_parse_image_header().

I've added a new config option (CONFIG_SYS_SPI_KERNEL_SKIP_HEADER) which
will skip the mkimage header check, allowing the subsequent
spl_parse_image_header() call to successfully fall through to bootz_setup()
and load/boot a raw kernel image.

Sincerely,
Nathan Barrett-Morrison
From e5a15a8ad2fd007e6d8d48dd64767d194bbd1833 Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Mon, 17 Jan 2022 19:42:59 -0500
Subject: [PATCH] Allow Falcon Mode boot to use raw kernel image when
 booting via SPI.  When using Falcon Mode boot with a raw, unwrapped kernel
 image, the bootz_setup() call inside of spl_parse_image_header() is
 unreachable because the mkimage header magic check will never pass.  Adding
 CONFIG_SYS_SPI_KERNEL_SKIP_HEADER gives us the ability to pass through to the
 desired bootz_setup() call.

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
Cc: Aneesh V 
---
 common/spl/spl_spi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 4e20a23dea..62dad1d2fb 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -33,8 +33,10 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
 	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
 		   (void *)header);
 
+#ifndef CONFIG_SYS_SPI_KERNEL_SKIP_HEADER
 	if (image_get_magic(header) != IH_MAGIC)
 		return -1;
+#endif
 
 	err = spl_parse_image_header(spl_image, header);
 	if (err)
-- 
2.34.1



Falcon Mode Support For Uncompressed Kernel Images

2022-01-17 Thread Nathan Barrett-Morrison
Hi All,

While trying to bring up Falcon Mode boot on an ARM64 board, I discovered
that there is no path which allows you to use an uncompressed kernel image
(booti).  I've added this path and attached the relevant patch.

I've made this a separate if/else CONFIG option instead of allowing both
bootz+booti paths to coexist, as it seems unlikely to me that there would
be such a board which needs both.  Most architectures use either bootz or
booti, but not both.

Sincerely,
Nathan Barrett-Morrison
From d5542ccc2d4f81ac0442be8ca772a99e1a13b6dd Mon Sep 17 00:00:00 2001
From: Nathan Barrett-Morrison 
Date: Mon, 17 Jan 2022 19:42:10 -0500
Subject: [PATCH] Add in the ability to load and boot an uncompressed
 kernel image during the Falcon Mode boot sequence.  This is required for
 architectures which do not support compressed kernel image booting (i.e.,
 ARM64)

Signed-off-by: Nathan Barrett-Morrison 
Cc: Tom Rini 
Cc: Aneesh V 
---
 arch/arm/lib/Makefile |  2 +-
 common/spl/Kconfig|  6 ++
 common/spl/spl.c  | 21 +
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index c48e1f622d..24c9e3c1e5 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -36,7 +36,7 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 else
 obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
-obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
+obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o image.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 4a739a7421..6d2c9f 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -917,6 +917,12 @@ config SYS_OS_BASE
 	  Specify the address, where the OS image is found, which
 	  gets booted.
 
+config SPL_OS_BOOT_UNCOMPRESSED
+	bool "Use uncompressed kernel image alongside Falcon Mode"
+	depends on SPL_SPI_LOAD
+	help
+	  Use an uncompressed kernel image to boot.  This is targetting
+	  architectures which use booti instead of bootz (i.e, ARM64).
 endif # SPL_OS_BOOT
 
 config SPL_PAYLOAD
diff --git a/common/spl/spl.c b/common/spl/spl.c
index f51d1f3205..9a826971eb 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -104,6 +104,11 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
 {
 	 return 1;
 }
+
+int __weak booti_setup(ulong image, ulong *relocated_addr, ulong *size, bool force_reloc)
+{
+	 return 1;
+}
 #endif
 
 /* Weak default function for arch/board-specific fixups to the spl_image_info */
@@ -354,6 +359,21 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 #endif
 
 #if CONFIG_IS_ENABLED(OS_BOOT)
+#if CONFIG_IS_ENABLED(OS_BOOT_UNCOMPRESSED)
+		ulong start, size;
+
+		if (!booti_setup((ulong)header, , , 0)) {
+			spl_image->name = "Linux";
+			spl_image->os = IH_OS_LINUX;
+			spl_image->load_addr = start;
+			spl_image->entry_point = start;
+			spl_image->size = size;
+			printf(SPL_TPL_PROMPT
+			  "payload Image, load addr: 0x%lx size: %d\n",
+			  spl_image->load_addr, spl_image->size);
+			return 0;
+		}
+#else
 		ulong start, end;
 
 		if (!bootz_setup((ulong)header, , )) {
@@ -367,6 +387,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 			  spl_image->load_addr, spl_image->size);
 			return 0;
 		}
+#endif
 #endif
 
 		if (!spl_parse_board_header(spl_image, (const void *)header, sizeof(*header)))
-- 
2.34.1