summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorFrancesco Valla <[email protected]>2026-06-04 22:41:37 +0200
committerTom Rini <[email protected]>2026-06-17 14:16:41 -0600
commitfffbb6f428ff81236d6092bec0d161904ca50335 (patch)
treed4513d07fec1c6fe0182d6a9208a0877dc96e8c2 /common
parent2a70a7e2252ecf01057592bb163a11cd337bcc95 (diff)
spl: fit: rework the FDT load hack
U-Boot proper expects its FDT to be right after its binary image; the "full" FIT image loader thus adopts an hack to relocate it, ignoring the specified load address. Rework the current form of the hack to: - support the 'sandbox' environment with a sysmem-aware memcpy; - use the ALIGN() macro instead of raw alignment logic; - align the FDT to 8-byte boundary as per FDT specifications; - fix the debug print (which was reporting the source address for the relocation instead of the destination one). Signed-off-by: Francesco Valla <[email protected]>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_fit.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 229eda0582f..1f3f7e54950 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -1000,14 +1000,15 @@ int spl_load_fit_image(struct spl_image_info *spl_image,
&fit_uname_config, IH_ARCH_DEFAULT, IH_TYPE_FLATDT,
-1, FIT_LOAD_OPTIONAL, &dt_data, &dt_len);
if (ret >= 0) {
- spl_image->fdt_addr = (void *)dt_data;
-
if (spl_image->os == IH_OS_U_BOOT) {
/* HACK: U-Boot expects FDT at a specific address */
- fdt_hack = spl_image->load_addr + spl_image->size;
- fdt_hack = (fdt_hack + 3) & ~3;
- debug("Relocating FDT to %p\n", spl_image->fdt_addr);
- memcpy((void *)fdt_hack, spl_image->fdt_addr, dt_len);
+ fdt_hack = ALIGN(spl_image->load_addr + spl_image->size, 8);
+ debug("Relocating FDT to %p\n", (void *)fdt_hack);
+ memcpy(map_sysmem(fdt_hack, dt_len),
+ map_sysmem(dt_data, 0), dt_len);
+ spl_image->fdt_addr = (void *)fdt_hack;
+ } else {
+ spl_image->fdt_addr = (void *)dt_data;
}
}