If the node describing an overlay does not specify a load address, it will
be loaded at the address previously used.
Fixing it by allocating a temporary 64kB region that will be used as a
default load address.

Signed-off-by: Jean-Jacques Hiblot <jjhib...@ti.com>
---

Changes in v2: None

 common/spl/spl_fit.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index a2909604cd..b54b30820e 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -9,6 +9,7 @@
 #include <fpga.h>
 #include <image.h>
 #include <linux/libfdt.h>
+#include <malloc.h>
 #include <spl.h>
 
 #ifndef CONFIG_SYS_BOOTM_LEN
@@ -302,6 +303,16 @@ static int spl_fit_append_fdt(struct spl_image_info 
*spl_image,
        spl_image->fdt_addr = (void *)image_info.load_addr;
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
 #if defined(CONFIG_OF_LIBFDT_OVERLAY)
+       void *tmpbuffer;
+       /*
+        * allocate 64kB of memory. This will be used to store the DT overlay
+        * before it is applied. It may not be used depending on how the
+        * overlay is stored.
+        */
+       tmpbuffer = malloc(64 * 1024);
+       if (!tmpbuffer)
+               debug("%s: unable to allocate space for overlays\n", __func__);
+
        for (; ; index++) {
                node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index);
                if (node < 0) {
@@ -309,6 +320,7 @@ static int spl_fit_append_fdt(struct spl_image_info 
*spl_image,
                        return 0;
                }
 
+               image_info.load_addr = (ulong) tmpbuffer;
                ret = spl_load_fit_image(info, sector, fit, base_offset, node,
                                         &image_info);
                if (ret < 0)
@@ -327,6 +339,8 @@ static int spl_fit_append_fdt(struct spl_image_info 
*spl_image,
                debug("%s: DT overlay %s applied\n", __func__,
                      fit_get_name(fit, node, NULL));
        }
+       if (tmpbuffer)
+               free(tmpbuffer);
 #endif
        /* Try to make space, so we can inject details on the loadables */
        ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
-- 
2.17.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to