[v2,33/49] x86: Makefile: Drop explicit targets built by binman

Message ID 20200613205717.v2.33.Ib6ee37195cb6d64579710219bae87005cc61d61f@changeid
State Accepted
Commit 42b18df80fdbbafc50b039201769b154b3ae533b
Headers show
Series
  • rockchip: x86: Support building ROM files automatically with binman
Related show

Commit Message

Simon Glass June 14, 2020, 2:57 a.m.
On x86 various files that need to be created by binman. It does not make
sense to enumerate these in the Makefile. They are described in the
configuration (devicetree) for each board and we can simply run binman
(always) to generate them.

Update the Makefile to have a separate, final step which runs binman,
once all input dependencies are present.

This avoid sprinkling the Makefile with arch-specific code.

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

(no changes since v1)

 Makefile                          | 63 ++++++++-----------------------
 arch/arm/dts/rockchip-u-boot.dtsi |  2 +
 2 files changed, 17 insertions(+), 48 deletions(-)

Comments

Bin Meng June 29, 2020, 7:44 a.m. | #1
Hi Simon,

On Sun, Jun 14, 2020 at 10:58 AM Simon Glass <sjg at chromium.org> wrote:
>
> On x86 various files that need to be created by binman. It does not make
> sense to enumerate these in the Makefile. They are described in the
> configuration (devicetree) for each board and we can simply run binman
> (always) to generate them.
>
> Update the Makefile to have a separate, final step which runs binman,
> once all input dependencies are present.
>
> This avoid sprinkling the Makefile with arch-specific code.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  Makefile                          | 63 ++++++++-----------------------
>  arch/arm/dts/rockchip-u-boot.dtsi |  2 +
>  2 files changed, 17 insertions(+), 48 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 875fbb1f1f..9c15dced7d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -916,16 +916,6 @@ INPUTS-$(CONFIG_REMAKE_ELF) += u-boot.elf
>  INPUTS-$(CONFIG_EFI_APP) += u-boot-app.efi
>  INPUTS-$(CONFIG_EFI_STUB) += u-boot-payload.efi
>
> -ifneq ($(CONFIG_HAS_ROM),)
> -ifneq ($(BUILD_ROM)$(CONFIG_BUILD_ROM),)
> -INPUTS-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
> -endif
> -endif
> -
> -ifeq ($(CONFIG_SYS_COREBOOT)$(CONFIG_SPL),yy)
> -INPUTS-$(CONFIG_BINMAN) += u-boot-x86-with-spl.bin
> -endif
> -
>  # Build a combined spl + u-boot image for sunxi
>  ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_SPL),yy)
>  INPUTS-y += u-boot-sunxi-with-spl.bin
> @@ -953,9 +943,13 @@ INPUTS-y += u-boot-with-dtb.bin
>  endif
>
>  ifeq ($(CONFIG_ARCH_ROCKCHIP)$(CONFIG_SPL),yy)
> -INPUTS-y += u-boot-rockchip.bin
> +INPUTS-y += u-boot-rockchip.bin idbloader.img

This change should not belong to this commit

>  endif
>
> +INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \
> +       $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
> +       $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin)
> +
>  LDFLAGS_u-boot += $(LDFLAGS_FINAL)
>
>  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
> @@ -1013,7 +1007,14 @@ cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
>  PHONY += inputs
>  inputs: $(INPUTS-y)
>
> -all: inputs
> +all: .binman_stamp inputs
> +ifeq ($(CONFIG_BINMAN),y)
> +       $(call if_changed,binman)
> +endif
> +
> +# Timestamp file to make sure that binman always runs
> +.binman_stamp: FORCE
> +       @touch $@
>
>  ifeq ($(CONFIG_DEPRECATED),y)
>         $(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.")
> @@ -1306,7 +1307,7 @@ quiet_cmd_binman = BINMAN  $@
>  cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
>                  --toolpath $(objtree)/tools \
>                 $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
> -               build -u -d u-boot.dtb -O . -m \
> +               build -u -d u-boot.dtb -O . -m --allow-missing \
>                 -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
>                 $(BINMAN_$(@F))
>
> @@ -1583,27 +1584,11 @@ u-boot-br.bin: u-boot FORCE
>  endif
>  endif
>
> -# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
> -# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in
> -# the middle. This is handled by binman based on an image description in the
> -# board's device tree.
> -ifneq ($(CONFIG_HAS_ROM),)
> -rom: u-boot.rom FORCE
> -
> -refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE
> -       $(call if_changed,copy)
> -
>  quiet_cmd_ldr = LD      $@
>  cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
>                $(filter-out FORCE,$^) -o $@
>
> -rom-deps := u-boot.bin
>  ifdef CONFIG_X86
> -rom-deps += u-boot-x86-start16.bin u-boot-x86-reset16.bin \
> -               $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
> -               $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) \
> -               $(if $(CONFIG_HAVE_REFCODE),refcode.bin)
> -
>  OBJCOPYFLAGS_u-boot-x86-start16.bin := -O binary -j .start16
>  u-boot-x86-start16.bin: u-boot FORCE
>         $(call if_changed,objcopy)
> @@ -1612,22 +1597,7 @@ OBJCOPYFLAGS_u-boot-x86-reset16.bin := -O binary -j .resetvec
>  u-boot-x86-reset16.bin: u-boot FORCE
>         $(call if_changed,objcopy)
>
> -else # !CONFIG_X86
> -
> -ifdef CONFIG_SPL
> -rom-deps += spl/u-boot-spl.bin
> -rom-deps += u-boot.img
> -endif
> -
> -ifdef CONFIG_TPL
> -rom-deps += tpl/u-boot-tpl.bin
> -endif
> -
> -endif
> -
> -u-boot.rom: $(rom-deps) FORCE
> -       $(call if_changed,binman)
> -endif
> +endif # CONFIG_X86
>
>  ifneq ($(CONFIG_ARCH_SUNXI),)
>  ifeq ($(CONFIG_ARM64),)
> @@ -1639,9 +1609,6 @@ u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.itb FORCE
>  endif
>  endif
>
> -u-boot-x86-with-spl.bin: spl/u-boot-spl.bin u-boot.bin FORCE
> -       $(call if_changed,binman)
> -
>  ifneq ($(CONFIG_ARCH_TEGRA),)
>  # Makes u-boot-dtb-tegra.bin u-boot-tegra.bin u-boot-nodtb-tegra.bin
>  %-dtb-tegra.bin %-tegra.bin %-nodtb-tegra.bin: spl/%-spl %.bin FORCE
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index 0451db735e..eae3ee715d 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -11,6 +11,7 @@
>         };
>  };
>
> +#ifdef CONFIG_SPL

This change should not belong to this commit

>  &binman {
>         simple-bin {
>                 filename = "u-boot-rockchip.bin";
> @@ -25,3 +26,4 @@
>                 };
>         };
>  };
> +#endif
> --

Regards,
Bin

Patch

diff --git a/Makefile b/Makefile
index 875fbb1f1f..9c15dced7d 100644
--- a/Makefile
+++ b/Makefile
@@ -916,16 +916,6 @@  INPUTS-$(CONFIG_REMAKE_ELF) += u-boot.elf
 INPUTS-$(CONFIG_EFI_APP) += u-boot-app.efi
 INPUTS-$(CONFIG_EFI_STUB) += u-boot-payload.efi
 
-ifneq ($(CONFIG_HAS_ROM),)
-ifneq ($(BUILD_ROM)$(CONFIG_BUILD_ROM),)
-INPUTS-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
-endif
-endif
-
-ifeq ($(CONFIG_SYS_COREBOOT)$(CONFIG_SPL),yy)
-INPUTS-$(CONFIG_BINMAN) += u-boot-x86-with-spl.bin
-endif
-
 # Build a combined spl + u-boot image for sunxi
 ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_SPL),yy)
 INPUTS-y += u-boot-sunxi-with-spl.bin
@@ -953,9 +943,13 @@  INPUTS-y += u-boot-with-dtb.bin
 endif
 
 ifeq ($(CONFIG_ARCH_ROCKCHIP)$(CONFIG_SPL),yy)
-INPUTS-y += u-boot-rockchip.bin
+INPUTS-y += u-boot-rockchip.bin idbloader.img
 endif
 
+INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \
+	$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
+	$(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin)
+
 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
@@ -1013,7 +1007,14 @@  cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
 PHONY += inputs
 inputs: $(INPUTS-y)
 
-all: inputs
+all: .binman_stamp inputs
+ifeq ($(CONFIG_BINMAN),y)
+	$(call if_changed,binman)
+endif
+
+# Timestamp file to make sure that binman always runs
+.binman_stamp: FORCE
+	@touch $@
 
 ifeq ($(CONFIG_DEPRECATED),y)
 	$(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.")
@@ -1306,7 +1307,7 @@  quiet_cmd_binman = BINMAN  $@
 cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
                 --toolpath $(objtree)/tools \
 		$(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
-		build -u -d u-boot.dtb -O . -m \
+		build -u -d u-boot.dtb -O . -m --allow-missing \
 		-I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
 		$(BINMAN_$(@F))
 
@@ -1583,27 +1584,11 @@  u-boot-br.bin: u-boot FORCE
 endif
 endif
 
-# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
-# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in
-# the middle. This is handled by binman based on an image description in the
-# board's device tree.
-ifneq ($(CONFIG_HAS_ROM),)
-rom: u-boot.rom FORCE
-
-refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE
-	$(call if_changed,copy)
-
 quiet_cmd_ldr = LD      $@
 cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
 	       $(filter-out FORCE,$^) -o $@
 
-rom-deps := u-boot.bin
 ifdef CONFIG_X86
-rom-deps += u-boot-x86-start16.bin u-boot-x86-reset16.bin \
-		$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
-		$(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) \
-		$(if $(CONFIG_HAVE_REFCODE),refcode.bin)
-
 OBJCOPYFLAGS_u-boot-x86-start16.bin := -O binary -j .start16
 u-boot-x86-start16.bin: u-boot FORCE
 	$(call if_changed,objcopy)
@@ -1612,22 +1597,7 @@  OBJCOPYFLAGS_u-boot-x86-reset16.bin := -O binary -j .resetvec
 u-boot-x86-reset16.bin: u-boot FORCE
 	$(call if_changed,objcopy)
 
-else # !CONFIG_X86
-
-ifdef CONFIG_SPL
-rom-deps += spl/u-boot-spl.bin
-rom-deps += u-boot.img
-endif
-
-ifdef CONFIG_TPL
-rom-deps += tpl/u-boot-tpl.bin
-endif
-
-endif
-
-u-boot.rom: $(rom-deps) FORCE
-	$(call if_changed,binman)
-endif
+endif # CONFIG_X86
 
 ifneq ($(CONFIG_ARCH_SUNXI),)
 ifeq ($(CONFIG_ARM64),)
@@ -1639,9 +1609,6 @@  u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.itb FORCE
 endif
 endif
 
-u-boot-x86-with-spl.bin: spl/u-boot-spl.bin u-boot.bin FORCE
-	$(call if_changed,binman)
-
 ifneq ($(CONFIG_ARCH_TEGRA),)
 # Makes u-boot-dtb-tegra.bin u-boot-tegra.bin u-boot-nodtb-tegra.bin
 %-dtb-tegra.bin %-tegra.bin %-nodtb-tegra.bin: spl/%-spl %.bin FORCE
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 0451db735e..eae3ee715d 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -11,6 +11,7 @@ 
 	};
 };
 
+#ifdef CONFIG_SPL
 &binman {
 	simple-bin {
 		filename = "u-boot-rockchip.bin";
@@ -25,3 +26,4 @@ 
 		};
 	};
 };
+#endif