[PATCH 07/14] fdt: Show a message when the working FDT changes

Simon Glass sjg at chromium.org
Fri Sep 9 17:17:54 CEST 2022


The working FDT is the one which comes from the OS and is fixed up by
U-Boot. When the bootm command runs, it sets up the working FDT to be the
one it is about to pass to the OS, so that fixups can happen.

This seems like an important step, so add a message indicating that the
working FDT has changed. This is shown during the running of the bootm
command.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 cmd/fdt.c             |  1 +
 doc/usage/cmd/fdt.rst |  1 +
 test/cmd/fdt.c        | 11 ++++++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 842e6cb634b..0afc7222c74 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -40,6 +40,7 @@ void set_working_fdt_addr(ulong addr)
 {
 	void *buf;
 
+	printf("Working FDT set to %lx\n", addr);
 	buf = map_sysmem(addr, 0);
 	working_fdt = buf;
 	env_set_hex("fdtaddr", addr);
diff --git a/doc/usage/cmd/fdt.rst b/doc/usage/cmd/fdt.rst
index 07fed732e45..36b8230877c 100644
--- a/doc/usage/cmd/fdt.rst
+++ b/doc/usage/cmd/fdt.rst
@@ -60,6 +60,7 @@ The second word shows the size of the FDT. Now set the working FDT to that
 address and expand it to 0xf000 in size::
 
     => fdt addr 10000 f000
+    Working FDT set to 10000
     => md 10000 4
     00010000: edfe0dd0 00f00000 78000000 7c270000  ...........x..'|
 
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 100a7ef5ebf..ba9eaa42c14 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -55,6 +55,7 @@ static int fdt_test_addr(struct unit_test_state *uts)
 
 	/* The working fdt is not set, so this should fail */
 	set_working_fdt_addr(0);
+	ut_assert_nextline("Working FDT set to 0");
 	ut_asserteq(CMD_RET_FAILURE, run_command("fdt addr", 0));
 	ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC");
 	ut_assertok(ut_check_console_end(uts));
@@ -63,18 +64,22 @@ static int fdt_test_addr(struct unit_test_state *uts)
 	ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt)));
 	addr = map_to_sysmem(fdt);
 	set_working_fdt_addr(addr);
+	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_assertok(run_command("fdt addr", 0));
 	ut_assert_nextline("Working fdt: %08lx", (ulong)map_to_sysmem(fdt));
 	ut_assertok(ut_check_console_end(uts));
 
 	/* Set the working FDT */
 	set_working_fdt_addr(0);
+	ut_assert_nextline("Working FDT set to 0");
 	ut_assertok(run_commandf("fdt addr %08x", addr));
+	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_asserteq(addr, map_to_sysmem(working_fdt));
 	ut_assertok(ut_check_console_end(uts));
 	set_working_fdt_addr(0);
+	ut_assert_nextline("Working FDT set to 0");
 
-	/* Set the working FDT */
+	/* Set the control FDT */
 	fdt_blob = gd->fdt_blob;
 	gd->fdt_blob = NULL;
 	ret = run_commandf("fdt addr -c %08x", addr);
@@ -93,6 +98,7 @@ static int fdt_test_addr(struct unit_test_state *uts)
 	/* Test detecting an invalid FDT */
 	fdt[0] = 123;
 	set_working_fdt_addr(addr);
+	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_asserteq(1, run_commandf("fdt addr"));
 	ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC");
 	ut_assertok(ut_check_console_end(uts));
@@ -115,16 +121,19 @@ static int fdt_test_resize(struct unit_test_state *uts)
 	/* Test setting and resizing the working FDT to a larger size */
 	ut_assertok(console_record_reset_enable());
 	ut_assertok(run_commandf("fdt addr %08x %x", addr, newsize));
+	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_assertok(ut_check_console_end(uts));
 
 	/* Try shrinking it */
 	ut_assertok(run_commandf("fdt addr %08x %x", addr, sizeof(fdt) / 4));
+	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_assert_nextline("New length %d < existing length %d, ignoring",
 			   (int)sizeof(fdt) / 4, newsize);
 	ut_assertok(ut_check_console_end(uts));
 
 	/* ...quietly */
 	ut_assertok(run_commandf("fdt addr -q %08x %x", addr, sizeof(fdt) / 4));
+	ut_assert_nextline("Working FDT set to %lx", addr);
 	ut_assertok(ut_check_console_end(uts));
 
 	/* We cannot easily provoke errors in fdt_open_into(), so ignore that */
-- 
2.37.2.789.g6183377224-goog



More information about the U-Boot mailing list