[PATCH] cmd: fdt: use U-Boot's FDT by default

Tom Rini trini at konsulko.com
Tue Sep 3 21:14:22 CEST 2024


On Sat, Aug 31, 2024 at 05:46:19PM +0100, Caleb Connolly wrote:

> When using the FDT command to inspect an arbitrary FDT in memory, it
> will always be necessary to explicitly set the FDT address. However it
> is also quite likely that the command is being used to inspect U-Boot's
> own FDT. Simplify that common workflow of running "fdt addr -c" to get
> the control address and set it by just making $fdtcontroladdr the
> default FDT if there isn't one.
> 
> Signed-off-by: Caleb Connolly <caleb.connolly at linaro.org>
> ---
>  cmd/fdt.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/cmd/fdt.c b/cmd/fdt.c
> index d16b141ce32d..8909706e2483 100644
> --- a/cmd/fdt.c
> +++ b/cmd/fdt.c
> @@ -276,8 +276,17 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  
>  		return CMD_RET_SUCCESS;
>  	}
>  
> +	/* Try using U-Boot's FDT by default */
> +	if (!working_fdt) {
> +		struct fdt_header *addr;
> +
> +		addr = (void *)env_get_hex("fdtcontroladdr", 0);
> +		if (addr && fdt_check_header(&addr))
> +			set_working_fdt_addr((phys_addr_t)addr);
> +	}
> +
>  	if (!working_fdt) {
>  		puts("No FDT memory address configured. Please configure\n"
>  		     "the FDT address via \"fdt addr <address>\" command.\n"
>  		     "Aborting!\n");

Setting aside the behavior change (which I am thinking about), this
makes the next check of !working_fdt dead code which should be removed.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20240903/13a23e46/attachment.sig>


More information about the U-Boot mailing list