[PATCH 47/71] bootstd: Include the device tree in the bootflow

Simon Glass sjg at chromium.org
Wed Dec 7 09:51:13 CET 2022


Some bootmeths provide a way to load a device tree as well as the base
OS image. Add a way to store this in the bootflow. Update the
'bootflow info' command to show this information.

Note that the device tree is not allocated, but instead is stored at
an address provided by an environment variable. This may need to be
adjusted at some point, but for now it works well and fits in with the
existing distro-boot scripts.

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

 boot/bootflow.c      | 1 +
 cmd/bootflow.c       | 6 ++++++
 include/bootflow.h   | 6 ++++++
 test/boot/bootflow.c | 1 +
 4 files changed, 14 insertions(+)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 8c01a4efdc9..21d4f6b5a9a 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -354,6 +354,7 @@ void bootflow_free(struct bootflow *bflow)
 	free(bflow->subdir);
 	free(bflow->fname);
 	free(bflow->buf);
+	free(bflow->fdt_fname);
 }
 
 void bootflow_remove(struct bootflow *bflow)
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 313103d2775..98c0d757b06 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -337,6 +337,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
 	printf("Filename:  %s\n", bflow->fname);
 	printf("Buffer:    %lx\n", (ulong)map_to_sysmem(bflow->buf));
 	printf("Size:      %x (%d bytes)\n", bflow->size, bflow->size);
+	printf("FDT:       %s\n", bflow->fdt_fname);
+	if (bflow->fdt_fname) {
+		printf("FDT size:  %x (%d bytes)\n", bflow->fdt_size,
+		       bflow->fdt_size);
+		printf("FDT addr:  %lx\n", bflow->fdt_addr);
+	}
 	printf("Error:     %d\n", bflow->err);
 	if (dump && bflow->buf) {
 		/* Set some sort of maximum on the size */
diff --git a/include/bootflow.h b/include/bootflow.h
index 905410974c8..f7b821fa10e 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -52,6 +52,9 @@ enum bootflow_state_t {
  * @buf: Bootflow file contents (allocated)
  * @size: Size of bootflow file in bytes
  * @err: Error number received (0 if OK)
+ * @fdt_fname: Filename of FDT file
+ * @fdt_size: Size of FDT file
+ * @fdt_addr: Address of loaded fdt
  */
 struct bootflow {
 	struct list_head bm_node;
@@ -68,6 +71,9 @@ struct bootflow {
 	char *buf;
 	int size;
 	int err;
+	char *fdt_fname;
+	int fdt_size;
+	ulong fdt_addr;
 };
 
 /**
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 9e9a3e4061c..7cbcfe1f08e 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -189,6 +189,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts)
 	ut_assert_nextline("Filename:  /extlinux/extlinux.conf");
 	ut_assert_nextlinen("Buffer:    ");
 	ut_assert_nextline("Size:      253 (595 bytes)");
+	ut_assert_nextline("FDT:       <NULL>");
 	ut_assert_nextline("Error:     0");
 	ut_assert_console_end();
 
-- 
2.39.0.rc0.267.gcb52ba06e7-goog



More information about the U-Boot mailing list