diff mbox series

cmd: add resize for FDT in bootelf

Message ID 20240628083411.19843-1-Maxim.Moskalets@kaspersky.com
State Accepted
Commit 8d57f46ab06d6e6178aa3ae321a5e58aa529b017
Delegated to: Tom Rini
Headers show
Series cmd: add resize for FDT in bootelf | expand

Commit Message

Maxim Moskalets June 28, 2024, 8:34 a.m. UTC
In some FDTs, there is not enough free memory to add nodes, so this
operation fails.

Signed-off-by: Maxim Moskalets <maximmosk4@gmail.com>
---
 cmd/elf.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Simon Glass June 29, 2024, 6:56 a.m. UTC | #1
Hi Maxim,

On Fri, 28 Jun 2024 at 09:34, Maxim Moskalets <maximmosk4@gmail.com> wrote:
>
> In some FDTs, there is not enough free memory to add nodes, so this
> operation fails.
>
> Signed-off-by: Maxim Moskalets <maximmosk4@gmail.com>
> ---
>  cmd/elf.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/cmd/elf.c b/cmd/elf.c
> index 32b7462f92..673c6c3051 100644
> --- a/cmd/elf.c
> +++ b/cmd/elf.c
> @@ -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;
>         }
> --
> 2.39.2
>

Reviewed-by: Simon Glass <sjg@chromium.org>

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
Maxim Moskalets June 30, 2024, 10:40 a.m. UTC | #2
Hi Simon,

On 29.06.2024 09:56, Simon Glass wrote:
> Hi Maxim,
>
> On Fri, 28 Jun 2024 at 09:34, Maxim Moskalets <maximmosk4@gmail.com> wrote:
>> In some FDTs, there is not enough free memory to add nodes, so this
>> operation fails.
>>
>> Signed-off-by: Maxim Moskalets <maximmosk4@gmail.com>
>> ---
>>   cmd/elf.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/cmd/elf.c b/cmd/elf.c
>> index 32b7462f92..673c6c3051 100644
>> --- a/cmd/elf.c
>> +++ b/cmd/elf.c
>> @@ -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;
>>          }
>> --
>> 2.39.2
>>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> 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
> You can also use the 'fdt addr <addr> <size>' to expand the FDT.
>
> Regards,
> Simon
Tom Rini July 11, 2024, 9:27 p.m. UTC | #3
On Fri, 28 Jun 2024 11:34:11 +0300, Maxim Moskalets wrote:

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

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/cmd/elf.c b/cmd/elf.c
index 32b7462f92..673c6c3051 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -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;
 	}