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 <asm/global_data.h>
 #include <dm/ofnode.h>
 
-#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, &load, 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,
        load.dev = flash;
        payload_offs = spl_spi_get_uboot_offs(flash);
 
-       header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
-
        if (CONFIG_IS_ENABLED(OF_REAL)) {
                payload_offs = ofnode_conf_read_int("u-boot,spl-payload-offset",
                                                    payload_offs);
        }
 
 #if CONFIG_IS_ENABLED(OS_BOOT)
-       if (spl_start_uboot() || spi_load_image_os(spl_image, bootdev, flash, 
header))
-#endif
-       {
-               /* Load u-boot, mkimage header is 64 bytes. */
-               err = spi_flash_read(flash, payload_offs, sizeof(*header),
-                                    (void *)header);
-               if (err) {
-                       debug("%s: Failed to read from SPI flash (err=%d)\n",
-                             __func__, err);
-                       return err;
-               }
-
-               err = spl_load(spl_image, bootdev, &load, header, 0,
-                              payload_offs);
+       if (spl_start_uboot()) {
+               err = spi_do_load_image(spl_image, bootdev, &load,
+                                       CONFIG_SYS_SPI_KERNEL_OFFS);
+               if (!err)
+                       /* Read device tree. */
+                       return spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
+                                             CONFIG_SYS_SPI_ARGS_SIZE,
+                                             (void *)CONFIG_SYS_SPL_ARGS_ADDR);
        }
+#endif
 
-       return err;
+       return spi_do_load_image(spl_image, bootdev, &load, payload_offs);
 }
 /* Use priorty 1 so that boards can override this */
 SPL_LOAD_IMAGE_METHOD("SPI", 1, BOOT_DEVICE_SPI, spl_spi_load_image);
-- 
2.35.1.1320.gc452695387.dirty

Reply via email to