diff mbox series

[v2,08/11] binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE

Message ID 20210508151512.14946-9-bmeng.cn@gmail.com
State Superseded
Headers show
Series riscv: Switch to use binman to generate u-boot.itb | expand

Commit Message

Bin Meng May 8, 2021, 3:15 p.m. UTC
For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
tree blob is explicitly required when using binman to package U-Boot.

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

---

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

 Makefile    |  3 ++-
 dts/Kconfig | 18 ++++++++++++++++++
 lib/Kconfig |  2 +-
 3 files changed, 21 insertions(+), 2 deletions(-)

Comments

Simon Glass May 8, 2021, 3:46 p.m. UTC | #1
Hi Bin,

On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> tree blob is explicitly required when using binman to package U-Boot.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
>
>  Makefile    |  3 ++-
>  dts/Kconfig | 18 ++++++++++++++++++
>  lib/Kconfig |  2 +-
>  3 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
>  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
>  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
>  endif
> @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
>  u-boot.bin: u-boot-dtb.bin FORCE
>         $(call if_changed,copy)
>  else
> -u-boot.bin: u-boot-nodtb.bin FORCE
> +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
>         $(call if_changed,copy)
>  endif
>
> diff --git a/dts/Kconfig b/dts/Kconfig
> index 99ce75e1a2..84d43fc6a4 100644
> --- a/dts/Kconfig
> +++ b/dts/Kconfig
> @@ -19,6 +19,24 @@ config BINMAN
>         bool
>         select DTOC
>
> +config BINMAN_DTB
> +       bool
> +       depends on BINMAN
> +       default y if OF_PRIOR_STAGE
> +       help
> +         This option tells U-Boot build system that a device tree blob is
> +         explicitly required when using binman to package U-Boot.
> +
> +         This is not necessary in a common scenario where a device tree blob
> +         is provided in the arch/<arch>/dts directory for a specific board,
> +         where the binman node has been put in the board's device tree, aka
> +         an implicit way. However for a scenario like the board's device tree
> +         is not provided in the U-Boot source tree, but given to U-Boot in the
> +         runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
> +         is passed by a prior stage bootloader. For such scenario, we will
> +         need to provide a device tree blob containing binman node to describe
> +         how to package U-Boot.

I don't fully understand the effect of this. Is binman (at build time)
using a binary DT provided by another build system? Or is it not
available at build time and binman cannot run?

The name is too vanilla I think. It should indicate that this is an
unusual situation.

> +
>  menu "Device Tree Control"
>         depends on SUPPORT_OF_CONTROL
>
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 6d2d41de30..7326d95357 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -25,7 +25,7 @@ config BCH
>  config BINMAN_FDT
>         bool "Allow access to binman information in the device tree"
>         depends on BINMAN && DM && OF_CONTROL
> -       default y
> +       default y if !BINMAN_DTB
>         help
>           This enables U-Boot to access information about binman entries,
>           stored in the device tree in a binman node. Typical uses are to
> --
> 2.25.1
>

Regards,
Simon
Bin Meng May 8, 2021, 3:55 p.m. UTC | #2
Hi Simon,

On Sat, May 8, 2021 at 11:47 PM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> > tree blob is explicitly required when using binman to package U-Boot.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > ---
> >
> > Changes in v2:
> > - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
> >
> >  Makefile    |  3 ++-
> >  dts/Kconfig | 18 ++++++++++++++++++
> >  lib/Kconfig |  2 +-
> >  3 files changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
> >  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
> >  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
> >  endif
> > @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> >  u-boot.bin: u-boot-dtb.bin FORCE
> >         $(call if_changed,copy)
> >  else
> > -u-boot.bin: u-boot-nodtb.bin FORCE
> > +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
> >         $(call if_changed,copy)
> >  endif
> >
> > diff --git a/dts/Kconfig b/dts/Kconfig
> > index 99ce75e1a2..84d43fc6a4 100644
> > --- a/dts/Kconfig
> > +++ b/dts/Kconfig
> > @@ -19,6 +19,24 @@ config BINMAN
> >         bool
> >         select DTOC
> >
> > +config BINMAN_DTB
> > +       bool
> > +       depends on BINMAN
> > +       default y if OF_PRIOR_STAGE
> > +       help
> > +         This option tells U-Boot build system that a device tree blob is
> > +         explicitly required when using binman to package U-Boot.
> > +
> > +         This is not necessary in a common scenario where a device tree blob
> > +         is provided in the arch/<arch>/dts directory for a specific board,
> > +         where the binman node has been put in the board's device tree, aka
> > +         an implicit way. However for a scenario like the board's device tree
> > +         is not provided in the U-Boot source tree, but given to U-Boot in the
> > +         runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
> > +         is passed by a prior stage bootloader. For such scenario, we will
> > +         need to provide a device tree blob containing binman node to describe
> > +         how to package U-Boot.
>
> I don't fully understand the effect of this. Is binman (at build time)
> using a binary DT provided by another build system? Or is it not
> available at build time and binman cannot run?

binman uses a DT provided by U-Boot, but that DT is only for binman if
OF_PRIOR_STAGE. For OF_SEPARATE / EMBEDDED, we can include binman node
there.

You can check patch 10 for how it works.

>
> The name is too vanilla I think. It should indicate that this is an
> unusual situation.

I cannot think of a good name :(

Regards,
Bin
Simon Glass May 8, 2021, 4:48 p.m. UTC | #3
Hi Bin,

On Sat, 8 May 2021 at 08:55, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Simon,
>
> On Sat, May 8, 2021 at 11:47 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Bin,
> >
> > On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > >
> > > For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> > > tree blob is explicitly required when using binman to package U-Boot.
> > >
> > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > >
> > > ---
> > >
> > > Changes in v2:
> > > - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
> > >
> > >  Makefile    |  3 ++-
> > >  dts/Kconfig | 18 ++++++++++++++++++
> > >  lib/Kconfig |  2 +-
> > >  3 files changed, 21 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
> > >  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
> > >  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
> > >  endif
> > > @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> > >  u-boot.bin: u-boot-dtb.bin FORCE
> > >         $(call if_changed,copy)
> > >  else
> > > -u-boot.bin: u-boot-nodtb.bin FORCE
> > > +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE

What is this change for, specifically? Can you add a comment?

It seems to be overriding the qemu thing of not actually building a DT?

> > >         $(call if_changed,copy)
> > >  endif
> > >
> > > diff --git a/dts/Kconfig b/dts/Kconfig
> > > index 99ce75e1a2..84d43fc6a4 100644
> > > --- a/dts/Kconfig
> > > +++ b/dts/Kconfig
> > > @@ -19,6 +19,24 @@ config BINMAN
> > >         bool
> > >         select DTOC
> > >
> > > +config BINMAN_DTB
> > > +       bool
> > > +       depends on BINMAN
> > > +       default y if OF_PRIOR_STAGE
> > > +       help
> > > +         This option tells U-Boot build system that a device tree blob is
> > > +         explicitly required when using binman to package U-Boot.
> > > +
> > > +         This is not necessary in a common scenario where a device tree blob
> > > +         is provided in the arch/<arch>/dts directory for a specific board,
> > > +         where the binman node has been put in the board's device tree, aka
> > > +         an implicit way. However for a scenario like the board's device tree
> > > +         is not provided in the U-Boot source tree, but given to U-Boot in the
> > > +         runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
> > > +         is passed by a prior stage bootloader. For such scenario, we will
> > > +         need to provide a device tree blob containing binman node to describe
> > > +         how to package U-Boot.
> >
> > I don't fully understand the effect of this. Is binman (at build time)
> > using a binary DT provided by another build system? Or is it not
> > available at build time and binman cannot run?
>
> binman uses a DT provided by U-Boot, but that DT is only for binman if
> OF_PRIOR_STAGE. For OF_SEPARATE / EMBEDDED, we can include binman node
> there.
>
> You can check patch 10 for how it works.

OK I think I get it.

>
> >
> > The name is too vanilla I think. It should indicate that this is an
> > unusual situation.
>
> I cannot think of a good name :(

How about BINMAN_FAKE_FDT ?

Why do you need to turn off BINMAN_FDT?

Regards,
Simon
Bin Meng May 8, 2021, 5:07 p.m. UTC | #4
Hi Simon,

On Sun, May 9, 2021 at 12:48 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Sat, 8 May 2021 at 08:55, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Simon,
> >
> > On Sat, May 8, 2021 at 11:47 PM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Hi Bin,
> > >
> > > On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > > >
> > > > For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> > > > tree blob is explicitly required when using binman to package U-Boot.
> > > >
> > > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > > >
> > > > ---
> > > >
> > > > Changes in v2:
> > > > - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
> > > >
> > > >  Makefile    |  3 ++-
> > > >  dts/Kconfig | 18 ++++++++++++++++++
> > > >  lib/Kconfig |  2 +-
> > > >  3 files changed, 21 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/Makefile b/Makefile
> > > > index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
> > > >  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
> > > >  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
> > > >  endif
> > > > @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> > > >  u-boot.bin: u-boot-dtb.bin FORCE
> > > >         $(call if_changed,copy)
> > > >  else
> > > > -u-boot.bin: u-boot-nodtb.bin FORCE
> > > > +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
>
> What is this change for, specifically? Can you add a comment?
>
> It seems to be overriding the qemu thing of not actually building a DT?
>
> > > >         $(call if_changed,copy)
> > > >  endif
> > > >
> > > > diff --git a/dts/Kconfig b/dts/Kconfig
> > > > index 99ce75e1a2..84d43fc6a4 100644
> > > > --- a/dts/Kconfig
> > > > +++ b/dts/Kconfig
> > > > @@ -19,6 +19,24 @@ config BINMAN
> > > >         bool
> > > >         select DTOC
> > > >
> > > > +config BINMAN_DTB
> > > > +       bool
> > > > +       depends on BINMAN
> > > > +       default y if OF_PRIOR_STAGE
> > > > +       help
> > > > +         This option tells U-Boot build system that a device tree blob is
> > > > +         explicitly required when using binman to package U-Boot.
> > > > +
> > > > +         This is not necessary in a common scenario where a device tree blob
> > > > +         is provided in the arch/<arch>/dts directory for a specific board,
> > > > +         where the binman node has been put in the board's device tree, aka
> > > > +         an implicit way. However for a scenario like the board's device tree
> > > > +         is not provided in the U-Boot source tree, but given to U-Boot in the
> > > > +         runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
> > > > +         is passed by a prior stage bootloader. For such scenario, we will
> > > > +         need to provide a device tree blob containing binman node to describe
> > > > +         how to package U-Boot.
> > >
> > > I don't fully understand the effect of this. Is binman (at build time)
> > > using a binary DT provided by another build system? Or is it not
> > > available at build time and binman cannot run?
> >
> > binman uses a DT provided by U-Boot, but that DT is only for binman if
> > OF_PRIOR_STAGE. For OF_SEPARATE / EMBEDDED, we can include binman node
> > there.
> >
> > You can check patch 10 for how it works.
>
> OK I think I get it.
>
> >
> > >
> > > The name is too vanilla I think. It should indicate that this is an
> > > unusual situation.
> >
> > I cannot think of a good name :(
>
> How about BINMAN_FAKE_FDT ?

Better than mine :)

If FAKE confuses people, maybe BINMAN_STANDALONE_FDT, or BINMAN_PACKAGE_FDT ?

>
> Why do you need to turn off BINMAN_FDT?

Because binman_init() fails on locating the image node in the device
tree, where the binman node does not exist at all. The DT used only
exists in the U-Boot build phase.

So here is what we have for different OF_CONTROL methods:

OF_SEPARATE / OF_EMBEDED: binman node is available in the DT (exists
along with other device nodes)
OF_PRIOR_STAGE: binman node is not available in the DT (DT only
contains the device nodes)

Regards,
Bin
Bin Meng May 8, 2021, 5:13 p.m. UTC | #5
On Sun, May 9, 2021 at 12:48 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Sat, 8 May 2021 at 08:55, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Simon,
> >
> > On Sat, May 8, 2021 at 11:47 PM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Hi Bin,
> > >
> > > On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > > >
> > > > For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> > > > tree blob is explicitly required when using binman to package U-Boot.
> > > >
> > > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > > >
> > > > ---
> > > >
> > > > Changes in v2:
> > > > - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
> > > >
> > > >  Makefile    |  3 ++-
> > > >  dts/Kconfig | 18 ++++++++++++++++++
> > > >  lib/Kconfig |  2 +-
> > > >  3 files changed, 21 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/Makefile b/Makefile
> > > > index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
> > > >  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
> > > >  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
> > > >  endif
> > > > @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> > > >  u-boot.bin: u-boot-dtb.bin FORCE
> > > >         $(call if_changed,copy)
> > > >  else
> > > > -u-boot.bin: u-boot-nodtb.bin FORCE
> > > > +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
>
> What is this change for, specifically? Can you add a comment?
>

Oops, I missed this comment. Sure.

> It seems to be overriding the qemu thing of not actually building a DT?

This is to make sure the dependency is met (ie: the *faked* DT
containing binman node gets built first) otherwise it may fail in a
parallel build.

Regards,
Bin
Simon Glass May 8, 2021, 5:21 p.m. UTC | #6
Hi Bin,

On Sat, 8 May 2021 at 10:07, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Simon,
>
> On Sun, May 9, 2021 at 12:48 AM Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Bin,
> >
> > On Sat, 8 May 2021 at 08:55, Bin Meng <bmeng.cn@gmail.com> wrote:
> > >
> > > Hi Simon,
> > >
> > > On Sat, May 8, 2021 at 11:47 PM Simon Glass <sjg@chromium.org> wrote:
> > > >
> > > > Hi Bin,
> > > >
> > > > On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > > > >
> > > > > For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> > > > > tree blob is explicitly required when using binman to package U-Boot.
> > > > >
> > > > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > > > >
> > > > > ---
> > > > >
> > > > > Changes in v2:
> > > > > - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
> > > > >
> > > > >  Makefile    |  3 ++-
> > > > >  dts/Kconfig | 18 ++++++++++++++++++
> > > > >  lib/Kconfig |  2 +-
> > > > >  3 files changed, 21 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/Makefile b/Makefile
> > > > > index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
> > > > >  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
> > > > >  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
> > > > >  endif
> > > > > @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> > > > >  u-boot.bin: u-boot-dtb.bin FORCE
> > > > >         $(call if_changed,copy)
> > > > >  else
> > > > > -u-boot.bin: u-boot-nodtb.bin FORCE
> > > > > +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
> >
> > What is this change for, specifically? Can you add a comment?
> >
> > It seems to be overriding the qemu thing of not actually building a DT?
> >
> > > > >         $(call if_changed,copy)
> > > > >  endif
> > > > >
> > > > > diff --git a/dts/Kconfig b/dts/Kconfig
> > > > > index 99ce75e1a2..84d43fc6a4 100644
> > > > > --- a/dts/Kconfig
> > > > > +++ b/dts/Kconfig
> > > > > @@ -19,6 +19,24 @@ config BINMAN
> > > > >         bool
> > > > >         select DTOC
> > > > >
> > > > > +config BINMAN_DTB
> > > > > +       bool
> > > > > +       depends on BINMAN
> > > > > +       default y if OF_PRIOR_STAGE
> > > > > +       help
> > > > > +         This option tells U-Boot build system that a device tree blob is
> > > > > +         explicitly required when using binman to package U-Boot.
> > > > > +
> > > > > +         This is not necessary in a common scenario where a device tree blob
> > > > > +         is provided in the arch/<arch>/dts directory for a specific board,
> > > > > +         where the binman node has been put in the board's device tree, aka
> > > > > +         an implicit way. However for a scenario like the board's device tree
> > > > > +         is not provided in the U-Boot source tree, but given to U-Boot in the
> > > > > +         runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
> > > > > +         is passed by a prior stage bootloader. For such scenario, we will
> > > > > +         need to provide a device tree blob containing binman node to describe
> > > > > +         how to package U-Boot.
> > > >
> > > > I don't fully understand the effect of this. Is binman (at build time)
> > > > using a binary DT provided by another build system? Or is it not
> > > > available at build time and binman cannot run?
> > >
> > > binman uses a DT provided by U-Boot, but that DT is only for binman if
> > > OF_PRIOR_STAGE. For OF_SEPARATE / EMBEDDED, we can include binman node
> > > there.
> > >
> > > You can check patch 10 for how it works.
> >
> > OK I think I get it.
> >
> > >
> > > >
> > > > The name is too vanilla I think. It should indicate that this is an
> > > > unusual situation.
> > >
> > > I cannot think of a good name :(
> >
> > How about BINMAN_FAKE_FDT ?
>
> Better than mine :)
>
> If FAKE confuses people, maybe BINMAN_STANDALONE_FDT, or BINMAN_PACKAGE_FDT ?

BINMAN_STANDALONE_FDT seems better actually

>
> >
> > Why do you need to turn off BINMAN_FDT?
>
> Because binman_init() fails on locating the image node in the device
> tree, where the binman node does not exist at all. The DT used only
> exists in the U-Boot build phase.

Oh yes I see. So confusing. Can you add some docs to binman about this?

>
> So here is what we have for different OF_CONTROL methods:
>
> OF_SEPARATE / OF_EMBEDED: binman node is available in the DT (exists

OF_EMBED

> along with other device nodes)
> OF_PRIOR_STAGE: binman node is not available in the DT (DT only
> contains the device nodes)

OK yes.

Regards,
Simon
Bin Meng May 8, 2021, 5:25 p.m. UTC | #7
Hi Simon,

On Sun, May 9, 2021 at 1:22 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Sat, 8 May 2021 at 10:07, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Simon,
> >
> > On Sun, May 9, 2021 at 12:48 AM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Hi Bin,
> > >
> > > On Sat, 8 May 2021 at 08:55, Bin Meng <bmeng.cn@gmail.com> wrote:
> > > >
> > > > Hi Simon,
> > > >
> > > > On Sat, May 8, 2021 at 11:47 PM Simon Glass <sjg@chromium.org> wrote:
> > > > >
> > > > > Hi Bin,
> > > > >
> > > > > On Sat, 8 May 2021 at 08:15, Bin Meng <bmeng.cn@gmail.com> wrote:
> > > > > >
> > > > > > For scenarios like 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_DTB is introduced, to tell U-Boot build system that a device
> > > > > > tree blob is explicitly required when using binman to package U-Boot.
> > > > > >
> > > > > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > >
> > > > > > ---
> > > > > >
> > > > > > Changes in v2:
> > > > > > - new patch: "binman: Support packaging U-Boot for scenarios like OF_PRIOR_STAGE"
> > > > > >
> > > > > >  Makefile    |  3 ++-
> > > > > >  dts/Kconfig | 18 ++++++++++++++++++
> > > > > >  lib/Kconfig |  2 +-
> > > > > >  3 files changed, 21 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/Makefile b/Makefile
> > > > > > index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
> > > > > >  ifeq ($(CONFIG_SPL_FRAMEWORK),y)
> > > > > >  INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
> > > > > >  endif
> > > > > > @@ -1161,7 +1162,7 @@ u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
> > > > > >  u-boot.bin: u-boot-dtb.bin FORCE
> > > > > >         $(call if_changed,copy)
> > > > > >  else
> > > > > > -u-boot.bin: u-boot-nodtb.bin FORCE
> > > > > > +u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
> > >
> > > What is this change for, specifically? Can you add a comment?
> > >
> > > It seems to be overriding the qemu thing of not actually building a DT?
> > >
> > > > > >         $(call if_changed,copy)
> > > > > >  endif
> > > > > >
> > > > > > diff --git a/dts/Kconfig b/dts/Kconfig
> > > > > > index 99ce75e1a2..84d43fc6a4 100644
> > > > > > --- a/dts/Kconfig
> > > > > > +++ b/dts/Kconfig
> > > > > > @@ -19,6 +19,24 @@ config BINMAN
> > > > > >         bool
> > > > > >         select DTOC
> > > > > >
> > > > > > +config BINMAN_DTB
> > > > > > +       bool
> > > > > > +       depends on BINMAN
> > > > > > +       default y if OF_PRIOR_STAGE
> > > > > > +       help
> > > > > > +         This option tells U-Boot build system that a device tree blob is
> > > > > > +         explicitly required when using binman to package U-Boot.
> > > > > > +
> > > > > > +         This is not necessary in a common scenario where a device tree blob
> > > > > > +         is provided in the arch/<arch>/dts directory for a specific board,
> > > > > > +         where the binman node has been put in the board's device tree, aka
> > > > > > +         an implicit way. However for a scenario like the board's device tree
> > > > > > +         is not provided in the U-Boot source tree, but given to U-Boot in the
> > > > > > +         runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
> > > > > > +         is passed by a prior stage bootloader. For such scenario, we will
> > > > > > +         need to provide a device tree blob containing binman node to describe
> > > > > > +         how to package U-Boot.
> > > > >
> > > > > I don't fully understand the effect of this. Is binman (at build time)
> > > > > using a binary DT provided by another build system? Or is it not
> > > > > available at build time and binman cannot run?
> > > >
> > > > binman uses a DT provided by U-Boot, but that DT is only for binman if
> > > > OF_PRIOR_STAGE. For OF_SEPARATE / EMBEDDED, we can include binman node
> > > > there.
> > > >
> > > > You can check patch 10 for how it works.
> > >
> > > OK I think I get it.
> > >
> > > >
> > > > >
> > > > > The name is too vanilla I think. It should indicate that this is an
> > > > > unusual situation.
> > > >
> > > > I cannot think of a good name :(
> > >
> > > How about BINMAN_FAKE_FDT ?
> >
> > Better than mine :)
> >
> > If FAKE confuses people, maybe BINMAN_STANDALONE_FDT, or BINMAN_PACKAGE_FDT ?
>
> BINMAN_STANDALONE_FDT seems better actually

Great :)

>
> >
> > >
> > > Why do you need to turn off BINMAN_FDT?
> >
> > Because binman_init() fails on locating the image node in the device
> > tree, where the binman node does not exist at all. The DT used only
> > exists in the U-Boot build phase.
>
> Oh yes I see. So confusing. Can you add some docs to binman about this?

Sure will update the doc on this.

>
> >
> > So here is what we have for different OF_CONTROL methods:
> >
> > OF_SEPARATE / OF_EMBEDED: binman node is available in the DT (exists
>
> OF_EMBED
>
> > along with other device nodes)
> > OF_PRIOR_STAGE: binman node is not available in the DT (DT only
> > contains the device nodes)
>
> OK yes.

Regards,
Bin
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 3d88559b67..9043828675 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_DTB) += u-boot.dtb
 ifeq ($(CONFIG_SPL_FRAMEWORK),y)
 INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
 endif
@@ -1161,7 +1162,7 @@  u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
 u-boot.bin: u-boot-dtb.bin FORCE
 	$(call if_changed,copy)
 else
-u-boot.bin: u-boot-nodtb.bin FORCE
+u-boot.bin: u-boot-nodtb.bin $(if $(CONFIG_BINMAN_DTB),dts/dt.dtb) FORCE
 	$(call if_changed,copy)
 endif
 
diff --git a/dts/Kconfig b/dts/Kconfig
index 99ce75e1a2..84d43fc6a4 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -19,6 +19,24 @@  config BINMAN
 	bool
 	select DTOC
 
+config BINMAN_DTB
+	bool
+	depends on BINMAN
+	default y if OF_PRIOR_STAGE
+	help
+	  This option tells U-Boot build system that a device tree blob is
+	  explicitly required when using binman to package U-Boot.
+
+	  This is not necessary in a common scenario where a device tree blob
+	  is provided in the arch/<arch>/dts directory for a specific board,
+	  where the binman node has been put in the board's device tree, aka
+	  an implicit way. However for a scenario like the board's device tree
+	  is not provided in the U-Boot source tree, but given to U-Boot in the
+	  runtime, e.g.: in the OF_PRIOR_STAGE case that the device tree blob
+	  is passed by a prior stage bootloader. For such scenario, we will
+	  need to provide a device tree blob containing binman node to describe
+	  how to package U-Boot.
+
 menu "Device Tree Control"
 	depends on SUPPORT_OF_CONTROL
 
diff --git a/lib/Kconfig b/lib/Kconfig
index 6d2d41de30..7326d95357 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -25,7 +25,7 @@  config BCH
 config BINMAN_FDT
 	bool "Allow access to binman information in the device tree"
 	depends on BINMAN && DM && OF_CONTROL
-	default y
+	default y if !BINMAN_DTB
 	help
 	  This enables U-Boot to access information about binman entries,
 	  stored in the device tree in a binman node. Typical uses are to