Hi Caleb, On Fri, 6 Sept 2024 at 03:31, Caleb Connolly <caleb.conno...@linaro.org> wrote: > > > > On 03/09/2024 20:14, Tom Rini wrote: > > 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.conno...@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. > > I wasn't sure if we could safely assume that fdtcontroladdr always > points to a valid FDT, if that's true then yes this can be dropped.
$ ./tools/qconfig.py -f ~OF_CONTROL 11 matches integratorap_cm720t integratorap_cm920t integratorap_cm926ejs integratorap_cm946es integratorcp_cm1136 integratorcp_cm920t integratorcp_cm926ejs integratorcp_cm946es mx6memcal work_92105 xtfpga So yes, there are boards where it would not be set. Regards, Simon