u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: trini@konsulko.com
Cc: "Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Simon Glass" <sjg@chromium.org>, "Pali Rohár" <pali@kernel.org>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"Chee Hong Ang" <chee.hong.ang@intel.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Sean Anderson" <seanga2@gmail.com>,
	"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
	"Stefan Roese" <sr@denx.de>,
	"Rasmus Villemoes" <rasmus.villemoes@prevas.dk>,
	"Nicolas Saenz Julienne" <nsaenzjulienne@suse.de>,
	"AKASHI Takahiro" <takahiro.akashi@linaro.org>,
	"Wasim Khan" <wasim.khan@nxp.com>,
	"Etienne Carriere" <etienne.carriere@linaro.org>,
	"Nandor Han" <nandor.han@vaisala.com>,
	"Alexandru Gagniuc" <mr.nuke.me@gmail.com>,
	"Steffen Jaeckel" <jaeckel-floss@eyet-services.de>,
	"Matthias Brugger" <mbrugger@suse.com>,
	"Alper Nebi Yasak" <alpernebiyasak@gmail.com>,
	"Heiko Schocher" <hs@denx.de>,
	"Asherah Connor" <ashe@kivikakk.ee>,
	"Andre Przywara" <andre.przywara@arm.com>,
	u-boot@lists.denx.de
Subject: [PATCH] sandbox: Remove OF_HOSTFILE
Date: Tue, 28 Sep 2021 12:05:40 +0300	[thread overview]
Message-ID: <20210928090544.186489-1-ilias.apalodimas@linaro.org> (raw)

OF_HOSTFILE is used on sandbox configs only.  Although it's pretty
unique not a source of any confusions,  we are better of having simple
config options for the DTB.
So let's replace that with the existing OF_BOARD.  This will make U-Boot
have only three different config options for the DTB origin.
- OF_SEPARATE, build separately from U-Boot
- OF_BOARD, board specific way of providing the DTB
- OF_EMBED embedded in the u-boot binary, but discouraged from being used
  in production

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 Makefile                                  |  6 +++---
 arch/sandbox/cpu/cpu.c                    | 21 ++++++++++++---------
 arch/sandbox/include/asm/u-boot-sandbox.h |  8 --------
 configs/sandbox64_defconfig               |  2 +-
 configs/sandbox_defconfig                 |  2 +-
 configs/sandbox_flattree_defconfig        |  2 +-
 configs/sandbox_noinst_defconfig          |  2 +-
 configs/sandbox_spl_defconfig             |  2 +-
 configs/tools-only_defconfig              |  2 +-
 doc/develop/devicetree/control.rst        |  7 +++----
 dts/Kconfig                               |  9 ---------
 lib/fdtdec.c                              |  5 -----
 scripts/Makefile.spl                      |  4 ++--
 13 files changed, 26 insertions(+), 46 deletions(-)

diff --git a/Makefile b/Makefile
index 3014788e14e8..cf3d98d00a62 100644
--- a/Makefile
+++ b/Makefile
@@ -957,7 +957,7 @@ INPUTS-$(CONFIG_BINMAN_STANDALONE_FDT) += u-boot.dtb
 ifeq ($(CONFIG_SPL_FRAMEWORK),y)
 INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
 endif
-INPUTS-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
+INPUTS-$(CONFIG_SANDBOX) += u-boot.dtb
 ifneq ($(CONFIG_SPL_TARGET),)
 INPUTS-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
@@ -1423,7 +1423,7 @@ u-boot-lzma.img: u-boot.bin.lzma FORCE
 
 u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \
 		$(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin \
-			$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE)$(CONFIG_BINMAN_STANDALONE_FDT),dts/dt.dtb) \
+			$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX)$(CONFIG_BINMAN_STANDALONE_FDT),dts/dt.dtb) \
 		,$(UBOOT_BIN)) FORCE
 	$(call if_changed,mkimage)
 	$(BOARD_SIZE_CHECK)
@@ -1437,7 +1437,7 @@ MKIMAGEFLAGS_u-boot.itb += -B 0x8
 
 ifdef U_BOOT_ITS
 u-boot.itb: u-boot-nodtb.bin \
-		$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE),dts/dt.dtb) \
+		$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
 		$(U_BOOT_ITS) FORCE
 	$(call if_changed,mkfitimage)
 	$(BOARD_SIZE_CHECK)
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 48636ab63919..bc67a5a5a10b 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -291,44 +291,47 @@ void invalidate_dcache_range(unsigned long start, unsigned long stop)
 {
 }
 
-int sandbox_read_fdt_from_file(void)
+void *board_fdt_blob_setup(void)
 {
 	struct sandbox_state *state = state_get_current();
 	const char *fname = state->fdt_fname;
-	void *blob;
+	void *blob = NULL;
 	loff_t size;
 	int err;
 	int fd;
 
+	printf("SETUP BLOB\n");
 	blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
 	if (!state->fdt_fname) {
 		err = fdt_create_empty_tree(blob, 256);
 		if (!err)
 			goto done;
 		printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
-		return -EINVAL;
+		goto fail;
 	}
 
 	err = os_get_filesize(fname, &size);
 	if (err < 0) {
 		printf("Failed to file FDT file '%s'\n", fname);
-		return err;
+		goto fail;
 	}
 	fd = os_open(fname, OS_O_RDONLY);
 	if (fd < 0) {
 		printf("Failed to open FDT file '%s'\n", fname);
-		return -EACCES;
+		goto fail;
 	}
+
 	if (os_read(fd, blob, size) != size) {
 		os_close(fd);
-		return -EIO;
+		printf("Failed to read file '%s'\n", fname);
+		goto fail;
 	}
 	os_close(fd);
 
 done:
-	gd->fdt_blob = blob;
-
-	return 0;
+	return blob;
+fail:
+	return NULL;
 }
 
 ulong timer_get_boot_us(void)
diff --git a/arch/sandbox/include/asm/u-boot-sandbox.h b/arch/sandbox/include/asm/u-boot-sandbox.h
index 73b1897191d5..56dc13c3eb11 100644
--- a/arch/sandbox/include/asm/u-boot-sandbox.h
+++ b/arch/sandbox/include/asm/u-boot-sandbox.h
@@ -76,14 +76,6 @@ int pci_unmap_physmem(const void *addr, unsigned long len,
  */
 void sandbox_set_enable_pci_map(int enable);
 
-/**
- * sandbox_read_fdt_from_file() - Read a device tree from a file
- *
- * Read a device tree file from a host file and set it up for use as the
- * control FDT.
- */
-int sandbox_read_fdt_from_file(void);
-
 /**
  * sandbox_reset() - reset sandbox
  *
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index f7098b496983..358a6c168259 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -86,7 +86,7 @@ CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIVE=y
-CONFIG_OF_HOSTFILE=y
+CONFIG_OF_BOARD=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_EXT4=y
 CONFIG_ENV_EXT4_INTERFACE="host"
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index ea08a9e5bd18..b8f8d8cf4454 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -110,7 +110,7 @@ CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIVE=y
-CONFIG_OF_HOSTFILE=y
+CONFIG_OF_BOARD=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_EXT4=y
 CONFIG_ENV_EXT4_INTERFACE="host"
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index a6e2544dc138..7aceaf5ad05b 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -67,7 +67,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
+CONFIG_OF_BOARD=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_EXT4=y
 CONFIG_ENV_EXT4_INTERFACE="host"
diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
index 88443f5ab274..8aec5df6f11b 100644
--- a/configs/sandbox_noinst_defconfig
+++ b/configs/sandbox_noinst_defconfig
@@ -85,7 +85,7 @@ CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
+CONFIG_OF_BOARD=y
 CONFIG_SPL_OF_PLATDATA=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_EXT4=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 77dd83cf6fdd..c889049c9132 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -86,7 +86,7 @@ CONFIG_MAC_PARTITION=y
 CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
+CONFIG_OF_BOARD=y
 CONFIG_SPL_OF_PLATDATA=y
 CONFIG_SPL_OF_PLATDATA_INST=y
 CONFIG_ENV_IS_NOWHERE=y
diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig
index f54bc1802ca7..ea38ef15532b 100644
--- a/configs/tools-only_defconfig
+++ b/configs/tools-only_defconfig
@@ -12,7 +12,7 @@ CONFIG_MISC_INIT_F=y
 CONFIG_BOOTP_DNS2=y
 # CONFIG_CMD_DATE is not set
 CONFIG_OF_CONTROL=y
-CONFIG_OF_HOSTFILE=y
+CONFIG_OF_BOARD=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_IP_DEFRAG=y
diff --git a/doc/develop/devicetree/control.rst b/doc/develop/devicetree/control.rst
index e84dfb6677a6..0e6f85d5af11 100644
--- a/doc/develop/devicetree/control.rst
+++ b/doc/develop/devicetree/control.rst
@@ -108,10 +108,9 @@ If CONFIG_OF_BOARD is defined, a board-specific routine will provide the
 devicetree at runtime, for example if an earlier bootloader stage creates
 it and passes it to U-Boot.
 
-If CONFIG_OF_HOSTFILE is defined, then it will be read from a file on
-startup. This is only useful for sandbox. Use the -d flag to U-Boot to
-specify the file to read, -D for the default and -T for the test devicetree,
-used to run sandbox unit tests.
+If CONFIG_SANDBOX is defined, then it will be read from a file on
+startup. Use the -d flag to U-Boot to specify the file to read, -D for the
+default and -T for the test devicetree, used to run sandbox unit tests.
 
 You cannot use more than one of these options at the same time.
 
diff --git a/dts/Kconfig b/dts/Kconfig
index 100769017e12..60d56cf6a907 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -108,20 +108,11 @@ config OF_EMBED
 
 config OF_BOARD
 	bool "Provided by the board (e.g a previous loader) at runtime"
-	depends on !SANDBOX
 	help
 	  If this option is enabled, the device tree will be provided by
 	  the board at runtime if the board supports it, instead of being
 	  bundled with the image.
 
-config OF_HOSTFILE
-	bool "Host filed DTB for DT control"
-	depends on SANDBOX
-	help
-	  If this option is enabled, DTB will be read from a file on startup.
-	  This is only useful for Sandbox.  Use the -d flag to U-Boot to
-	  specify the file to read.
-
 endchoice
 
 config DEFAULT_DEVICE_TREE
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 7b379564600d..e84472dc2e59 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1575,11 +1575,6 @@ int fdtdec_setup(void)
 # elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
 	/* Allow the board to override the fdt address. */
 	gd->fdt_blob = board_fdt_blob_setup();
-# elif defined(CONFIG_OF_HOSTFILE)
-	if (sandbox_read_fdt_from_file()) {
-		puts("Failed to read control FDT\n");
-		return -1;
-	}
 # endif
 # ifndef CONFIG_SPL_BUILD
 	/* Allow the early environment to override the fdt address */
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 25a3e7fa52e9..fa362495e1b4 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -298,11 +298,11 @@ endif
 # Build the .dtb file if:
 #   - we are not using OF_PLATDATA
 #   - we are using OF_CONTROL
-#   - we have either OF_SEPARATE or OF_HOSTFILE
+#   - we have either OF_SEPARATE or we are compiling for sandbox
 build_dtb :=
 ifeq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA),)
 ifneq ($(CONFIG_$(SPL_TPL_)OF_CONTROL),)
-ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_OF_HOSTFILE),y)
+ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_SANDBOX_SPL),y)
 build_dtb := y
 endif
 endif
-- 
2.33.0


             reply	other threads:[~2021-09-28  9:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28  9:05 Ilias Apalodimas [this message]
2021-09-28  9:05 ` [PATCH] sandbox: Remove OF_HOSTFILE Ilias Apalodimas
2021-09-28 22:46   ` Simon Glass
2021-09-29  5:39     ` Ilias Apalodimas
2021-09-29  6:25       ` Ilias Apalodimas
2021-09-29  7:44         ` Heinrich Schuchardt
2021-10-11 19:20           ` Simon Glass
2021-10-11 20:16             ` Ilias Apalodimas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210928090544.186489-1-ilias.apalodimas@linaro.org \
    --to=ilias.apalodimas@linaro.org \
    --cc=alpernebiyasak@gmail.com \
    --cc=andre.przywara@arm.com \
    --cc=ashe@kivikakk.ee \
    --cc=bmeng.cn@gmail.com \
    --cc=chee.hong.ang@intel.com \
    --cc=etienne.carriere@linaro.org \
    --cc=hs@denx.de \
    --cc=jaeckel-floss@eyet-services.de \
    --cc=marek.behun@nic.cz \
    --cc=mbrugger@suse.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=nandor.han@vaisala.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=pali@kernel.org \
    --cc=patrick.delaunay@foss.st.com \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=sr@denx.de \
    --cc=takahiro.akashi@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wasim.khan@nxp.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).