In cases where the 'load' property is not defined in a FIT image node,
fallback to using the data address returned by `fit_image_get_data()`.
This enables FIT images to omit the 'load' property during FIT creation.

Signed-off-by: Beleswar Padhi <b-pa...@ti.com>
---
v2: Changelog:
1. New patch. Add support to load images without 'load' property.

 common/spl/spl_fit.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 86506d6905c..bf26f96c77b 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -742,6 +742,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 {
        struct spl_image_info image_info;
        struct spl_fit_info ctx;
+       const void *fit_image_loadaddr;
+       size_t fit_image_size;
        int node = -1;
        int ret;
        int index = 0;
@@ -832,7 +834,19 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
                if (firmware_node == node)
                        continue;
 
-               image_info.load_addr = 0;
+               /*
+                * If the 'load' property is not present in the image node,
+                * use the FIT image's data address as the fallback load
+                * address. This allows flexibility in omitting the load address
+                * during FIT creation time.
+                */
+               ret = fit_image_get_data(ctx.fit, node,
+                                        &fit_image_loadaddr, &fit_image_size);
+               if (ret < 0)
+                       panic("Error accessing node = %d in FIT (%d)\n", node,
+                             ret);
+
+               image_info.load_addr = (ulong)fit_image_loadaddr;
                ret = load_simple_fit(info, offset, &ctx, node, &image_info);
                if (ret < 0 && ret != -EPERM) {
                        printf("%s: can't load image loadables index %d (ret = 
%d)\n",
-- 
2.34.1

Reply via email to