diff mbox series

[v5,09/13] binman: Support packaging U-Boot for scenarios like OF_BOARD or OF_PRIOR_STAGE

Message ID 20210510122341.13798-10-bmeng.cn@gmail.com
State Accepted
Commit 31eefd4380b2d0e6c251360b883cdad889ab2fe1
Delegated to: Andes
Headers show
Series riscv: Switch to use binman to generate u-boot.itb | expand

Commit Message

Bin Meng May 10, 2021, 12:23 p.m. UTC
For scenarios like OF_BOARD or OF_PRIOR_STAGE, no device tree blob is
provided in the U-Boot build phase hence the binman node information
is not available. In order to support such use case, a new Kconfig
option BINMAN_STANDALONE_FDT is introduced, to tell the build system
that a device tree blob containing binman node is explicitly required
when using binman to package U-Boot.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v5:
- update binman.rst for OF_BOARD or OF_PRIOR_STAGE usage

Changes in v4:
- update the makefile dependency on u-boot.img instead of u-boot.bin

Changes in v3:
- rename the Kconfig option name to BINMAN_STANDALONE_FDT
- make BINMAN_STANDALONE_FDT default y for OF_BOARD as well
- reword the Kconfig option help message a little bit

Changes in v2:
- new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"

 Makefile                |  3 ++-
 dts/Kconfig             | 18 ++++++++++++++++++
 tools/binman/binman.rst | 24 ++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)

Comments

Simon Glass May 10, 2021, 4:28 p.m. UTC | #1
On Mon, 10 May 2021 at 06:24, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> For scenarios like OF_BOARD or OF_PRIOR_STAGE, no device tree blob is
> provided in the U-Boot build phase hence the binman node information
> is not available. In order to support such use case, a new Kconfig
> option BINMAN_STANDALONE_FDT is introduced, to tell the build system
> that a device tree blob containing binman node is explicitly required
> when using binman to package U-Boot.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v5:
> - update binman.rst for OF_BOARD or OF_PRIOR_STAGE usage
>
> Changes in v4:
> - update the makefile dependency on u-boot.img instead of u-boot.bin
>
> Changes in v3:
> - rename the Kconfig option name to BINMAN_STANDALONE_FDT
> - make BINMAN_STANDALONE_FDT default y for OF_BOARD as well
> - reword the Kconfig option help message a little bit
>
> Changes in v2:
> - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
>
>  Makefile                |  3 ++-
>  dts/Kconfig             | 18 ++++++++++++++++++
>  tools/binman/binman.rst | 24 ++++++++++++++++++++++++
>  3 files changed, 44 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 3d88559b67..1dbf0b0b8c 100644
--- a/Makefile
+++ b/Makefile
@@ -918,6 +918,7 @@  endif
 endif
 INPUTS-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
 INPUTS-$(CONFIG_OF_SEPARATE) += u-boot.dtb
+INPUTS-$(CONFIG_BINMAN_STANDALONE_FDT) += u-boot.dtb
 ifeq ($(CONFIG_SPL_FRAMEWORK),y)
 INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
 endif
@@ -1392,7 +1393,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),dts/dt.dtb) \
+			$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE)$(CONFIG_BINMAN_STANDALONE_FDT),dts/dt.dtb) \
 		,$(UBOOT_BIN)) FORCE
 	$(call if_changed,mkimage)
 	$(BOARD_SIZE_CHECK)
diff --git a/dts/Kconfig b/dts/Kconfig
index 99ce75e1a2..dabe0080c1 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -19,6 +19,24 @@  config BINMAN
 	bool
 	select DTOC
 
+config BINMAN_STANDALONE_FDT
+	bool
+	depends on BINMAN
+	default y if OF_BOARD || OF_PRIOR_STAGE
+	help
+	  This option tells U-Boot build system that a standalone device tree
+	  source is explicitly required when using binman to package U-Boot.
+
+	  This is not necessary in a common scenario where a device tree source
+	  that contains the binman node is provided in the arch/<arch>/dts
+	  directory for a specific board. Such device tree sources are built for
+	  OF_SEPARATE or OF_EMBED. However for a scenario like the board device
+	  tree blob is not provided in the U-Boot build tree, but fed to U-Boot
+	  in the runtime, e.g.: in the OF_PRIOR_STAGE case that it is passed by
+	  a prior stage bootloader. For such scenario, a standalone device tree
+	  blob containing binman node to describe how to package U-Boot should
+	  be provided explicitly.
+
 menu "Device Tree Control"
 	depends on SUPPORT_OF_CONTROL
 
diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index b3df3a6428..bc635aa00a 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -232,6 +232,30 @@  You can use other, more specific CONFIG options - see 'Automatic .dtsi
 inclusion' below.
 
 
+Using binman with OF_BOARD or OF_PRIOR_STAGE
+--------------------------------------------
+
+Normally binman is used with a board configured with OF_SEPARATE or OF_EMBED.
+This is a typical scenario where a device tree source that contains the binman
+node is provided in the arch/<arch>/dts directory for a specific board.
+
+However for a board configured with OF_BOARD or OF_PRIOR_STAGE, no device tree
+blob is provided in the U-Boot build phase hence the binman node information
+is not available. In order to support such use case, a new Kconfig option
+BINMAN_STANDALONE_FDT is introduced, to tell the build system that a standalone
+device tree blob containing binman node is explicitly required.
+
+Note there is a Kconfig option BINMAN_FDT which enables U-Boot run time to
+access information about binman entries, stored in the device tree in a binman
+node. Generally speaking, this option makes sense for OF_SEPARATE or OF_EMBED.
+For the other OF_CONTROL methods, it's quite possible binman node is not
+available as binman is invoked during the build phase, thus this option is not
+turned on by default for these OF_CONTROL methods.
+
+See qemu-riscv64_spl_defconfig for an example of how binman is used with
+OF_PRIOR_STAGE to generate u-boot.itb image.
+
+
 Access to binman entry offsets at run time (symbols)
 ----------------------------------------------------