Skip to contentSkip to conversation

cmd: add resize for FDT in bootelf

PATCH In review Maxim Moskalets 3 participants 4 messages Jun 28, 2024 – Jul 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: add resize for FDT in bootelf

In some FDTs, there is not enough free memory to add nodes, so this operation fails.

---
 cmd/elf.c | 2 ++
 1 file changed, 2 insertions(+)
cmd/elf.c +2 -0
index 32b7462f92..673c6c3051 100644
@@ -68,6 +68,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr);
 		flush();
 
+		fdt_set_totalsize((void *)fdt_addr,
+				fdt_totalsize(fdt_addr) + CONFIG_SYS_FDT_PAD);
 		if (image_setup_libfdt(&img, (void *)fdt_addr, NULL))
 			return 1;
 	}
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Maxim,

Quoted 23 lines · Maxim Moskalets

In some FDTs, there is not enough free memory to add nodes, so this operation fails.

---
 cmd/elf.c | 2 ++
 1 file changed, 2 insertions(+)
cmd/elf.c +2 -1
index 32b7462f92..673c6c3051 100644
@@ -68,6 +68,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr);
                flush();
 
+               fdt_set_totalsize((void *)fdt_addr,
+                               fdt_totalsize(fdt_addr) + CONFIG_SYS_FDT_PAD);
                if (image_setup_libfdt(&img, (void *)fdt_addr, NULL))
                        return 1;
        }
--
Quoted 2 lines

2.39.2

Would you mind adding some docs for this comment in doc/usage/cmd/elf.rst ?

You can also use the 'fdt addr <addr> <size>' to expand the FDT.

Regards,
Simon

#2 lore raw

Hi Simon,

Quoted 29 lines · Simon Glass

Hi Maxim,

Quoted 22 lines · Maxim Moskalets

In some FDTs, there is not enough free memory to add nodes, so this operation fails.

---
  cmd/elf.c | 2 ++
  1 file changed, 2 insertions(+)
cmd/elf.c +2 -1
index 32b7462f92..673c6c3051 100644
@@ -68,6 +68,8 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                 log_debug("Setting up FDT at 0x%08lx ...\n", fdt_addr);
                 flush();
 
+               fdt_set_totalsize((void *)fdt_addr,
+                               fdt_totalsize(fdt_addr) + CONFIG_SYS_FDT_PAD);
                 if (image_setup_libfdt(&img, (void *)fdt_addr, NULL))
                         return 1;
         }
--
Quoted 2 lines

2.39.2

Quoted 1 line

Would you mind adding some docs for this comment in doc/usage/cmd/elf.rst ?

I added the documentation, but since it's not relevant to this patch, it's in the [PATCH] doc: add bootelf command documentation

Regards,
Maxim

Quoted 4 lines

You can also use the 'fdt addr <addr> <size>' to expand the FDT.

Regards,
Simon

#3 lore raw
In reply to Maxim Moskalets
Quoted 4 lines · Maxim Moskalets

In some FDTs, there is not enough free memory to add nodes, so this operation fails.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom