summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorJean-Jacques Hiblot <jjhiblot@ti.com>2019-10-22 16:39:12 +0200
committerTom Rini <trini@konsulko.com>2020-01-07 11:12:47 -0500
commit99329be2c58d53ccf8f597bab3de85f4c572b152 (patch)
tree1faf4e8347dde0e46a7a6dbb263278a5b3bcaa75 /common/spl
parent9d13b8725481ee5651c6e881e5d336142b813b14 (diff)
spl: fit: Make room in the FDT before applying overlays
Make room in the FDT before applying the overlay, otherwise it may fail if the overlay is big. As the exact added size is not known in advance, just add the size of the overlay. Move after the end of the application of the overlays, the resize of the FDT for the injection of the details on the loadables. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/spl_fit.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 39e406b237..65dd835ecc 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -313,11 +313,6 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
/* Make the load-address of the FDT available for the SPL framework */
spl_image->fdt_addr = (void *)image_info.load_addr;
#if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
- /* Try to make space, so we can inject details on the loadables */
- ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
- if (ret < 0)
- return ret;
-#endif
if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
for (; ; index++) {
node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
@@ -332,6 +327,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
if (ret < 0)
return ret;
+ /* Make room in FDT for changes from the overlay */
+ ret = fdt_increase_size(spl_image->fdt_addr,
+ image_info.size);
+ if (ret < 0)
+ return ret;
+
ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
(void *)image_info.load_addr);
if (ret)
@@ -341,6 +342,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
fit_get_name(fit, node, NULL));
}
}
+ /* Try to make space, so we can inject details on the loadables */
+ ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
+ if (ret < 0)
+ return ret;
+#endif
+
return ret;
}