diff mbox series

[v2,22/49] x86: rockchip: Change how selection of ROMs works

Message ID 20200614025728.41065-5-sjg@chromium.org
State Accepted
Commit bcd4e6f3bd79faef0e57f5ff8adc8b6b4ecfa005
Headers show
Series rockchip: x86: Support building ROM files automatically with binman | expand

Commit Message

Simon Glass June 14, 2020, 2:57 a.m. UTC
Most x86 boards build a u-boot.rom which is programmed into SPI flash. But
this is not unique to x86. For example some rockchip boards can also boot
from SPI flash.

Also, at least on x86, binary blobs are sadly quite common. It is not
possible to build a functional image without them, and U-Boot needs to
know this at build time.

Introduce a new CONFIG_HAS_ROM option which selects whether u-boot.rom is
built and a new CONFIG_ROM_NEEDS_BLOBS option to indicate whether binary
blobs are also needed. If they are not needed, it is safe to build the ROM
always. Otherwise we still require the BUILD_ROM environment variable.

For now this affects only x86, but future patches will enable this for
rockchip too.

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

(no changes since v1)

 Kconfig                       | 18 +++++++++++++++++-
 Makefile                      | 18 +++++++++++++-----
 arch/Kconfig                  |  1 +
 arch/x86/Kconfig              |  4 ++++
 arch/x86/cpu/baytrail/Kconfig |  1 +
 arch/x86/cpu/quark/Kconfig    |  1 +
 6 files changed, 37 insertions(+), 6 deletions(-)

Comments

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

On Sun, Jun 14, 2020 at 10:57 AM Simon Glass <sjg at chromium.org> wrote:
>
> Most x86 boards build a u-boot.rom which is programmed into SPI flash. But
> this is not unique to x86. For example some rockchip boards can also boot
> from SPI flash.
>
> Also, at least on x86, binary blobs are sadly quite common. It is not
> possible to build a functional image without them, and U-Boot needs to
> know this at build time.
>
> Introduce a new CONFIG_HAS_ROM option which selects whether u-boot.rom is
> built and a new CONFIG_ROM_NEEDS_BLOBS option to indicate whether binary
> blobs are also needed. If they are not needed, it is safe to build the ROM
> always. Otherwise we still require the BUILD_ROM environment variable.
>
> For now this affects only x86, but future patches will enable this for
> rockchip too.

The commit tag has rockchip, but this patch only affects x86 for now.
Remove this tag?

>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  Kconfig                       | 18 +++++++++++++++++-
>  Makefile                      | 18 +++++++++++++-----
>  arch/Kconfig                  |  1 +
>  arch/x86/Kconfig              |  4 ++++
>  arch/x86/cpu/baytrail/Kconfig |  1 +
>  arch/x86/cpu/quark/Kconfig    |  1 +
>  6 files changed, 37 insertions(+), 6 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index 0e7ccc0b07..876c5db911 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -240,9 +240,25 @@ config PHYS_64BIT
>           This can be used not only for 64bit SoCs, but also for
>           large physical address extension on 32bit SoCs.
>
> +config HAS_ROM
> +       bool
> +       select BINMAN
> +       help
> +         Enables building of a u-boot.rom target. This collects U-Boot and
> +         any necessary binary blobs.
> +
> +config ROM_NEEDS_BLOBS
> +       bool
> +       depends on HAS_ROM
> +       help
> +         Enable this if building the u-boot.rom target needs binary blobs, and
> +         so cannot be done normally. In this case, pass BUILD_ROM=1 to make
> +         to tell U-Boot to build the ROM.
> +
>  config BUILD_ROM
>         bool "Build U-Boot as BIOS replacement"
> -       depends on X86
> +       depends on HAS_ROM
> +       default y if !ROM_NEEDS_BLOBS
>         help
>           This option allows to build a ROM version of U-Boot.
>           The build process generally requires several binary blobs
> diff --git a/Makefile b/Makefile
> index 149f839948..8a2bb94f2c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -916,9 +916,12 @@ ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
>  ALL-$(CONFIG_EFI_APP) += u-boot-app.efi
>  ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
>
> +ifneq ($(CONFIG_HAS_ROM),)
>  ifneq ($(BUILD_ROM)$(CONFIG_BUILD_ROM),)
> -ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
> +ALL-y += u-boot.rom
>  endif
> +endif
> +
>  ifeq ($(CONFIG_SYS_COREBOOT)$(CONFIG_SPL),yy)
>  ALL-$(CONFIG_BINMAN) += u-boot-x86-with-spl.bin
>  endif
> @@ -1580,7 +1583,7 @@ endif
>  # 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_X86_RESET_VECTOR),)
> +ifneq ($(CONFIG_HAS_ROM),)
>  rom: u-boot.rom FORCE
>
>  refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE
> @@ -1590,11 +1593,12 @@ quiet_cmd_ldr = LD      $@
>  cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
>                $(filter-out FORCE,$^) -o $@
>
> -u-boot.rom: u-boot-x86-start16.bin u-boot-x86-reset16.bin u-boot.bin \
> +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) FORCE
> -       $(call if_changed,binman)
> +               $(if $(CONFIG_HAVE_REFCODE),refcode.bin)
>
>  OBJCOPYFLAGS_u-boot-x86-start16.bin := -O binary -j .start16
>  u-boot-x86-start16.bin: u-boot FORCE
> @@ -1605,6 +1609,10 @@ u-boot-x86-reset16.bin: u-boot FORCE
>         $(call if_changed,objcopy)
>  endif
>
> +u-boot.rom: $(rom-deps) FORCE
> +       $(call if_changed,binman)
> +endif
> +
>  ifneq ($(CONFIG_ARCH_SUNXI),)
>  ifeq ($(CONFIG_ARM64),)
>  u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
> diff --git a/arch/Kconfig b/arch/Kconfig
> index a11f872938..ff417d40fd 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -160,6 +160,7 @@ config X86
>         select TIMER
>         select USE_PRIVATE_LIBGCC
>         select X86_TSC_TIMER
> +       imply HAS_ROM if X86_RESET_VECTOR
>         imply BLK
>         imply CMD_DM
>         imply CMD_FPGA_LOADMK
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index c8eae24c07..c688c46475 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -360,6 +360,8 @@ config HAVE_FSP
>         bool "Add an Firmware Support Package binary"
>         depends on !EFI
>         select USE_HOB
> +       select HAS_ROM
> +       select ROM_NEEDS_BLOBS
>         help
>           Select this option to add an Firmware Support Package binary to
>           the resulting U-Boot image. It is a binary blob which U-Boot uses
> @@ -519,6 +521,8 @@ config ENABLE_MRC_CACHE
>
>  config HAVE_MRC
>         bool "Add a System Agent binary"
> +       select HAS_ROM
> +       select ROM_NEEDS_BLOBS
>         depends on !HAVE_FSP
>         help
>           Select this option to add a System Agent binary to
> diff --git a/arch/x86/cpu/baytrail/Kconfig b/arch/x86/cpu/baytrail/Kconfig
> index d2c3473d6a..53d945e931 100644
> --- a/arch/x86/cpu/baytrail/Kconfig
> +++ b/arch/x86/cpu/baytrail/Kconfig
> @@ -7,6 +7,7 @@ config INTEL_BAYTRAIL
>         select HAVE_FSP
>         select ARCH_MISC_INIT
>         select CPU_INTEL_TURBO_NOT_PACKAGE_SCOPED
> +       imply ROM_NEEDS_BLOBS

This is already selected by HAVE_FSP

>         imply HAVE_INTEL_ME
>         imply ENABLE_MRC_CACHE
>         imply AHCI_PCI
> diff --git a/arch/x86/cpu/quark/Kconfig b/arch/x86/cpu/quark/Kconfig
> index 430cce184d..2fee38aed7 100644
> --- a/arch/x86/cpu/quark/Kconfig
> +++ b/arch/x86/cpu/quark/Kconfig
> @@ -24,6 +24,7 @@ if INTEL_QUARK
>
>  config HAVE_RMU
>         bool "Add a Remote Management Unit (RMU) binary"
> +       select ROM_NEEDS_BLOBS
>         help
>           Select this option to add a Remote Management Unit (RMU) binary
>           to the resulting U-Boot image. It is a data block (up to 64K) of
> --

Regards,
Bin
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index 0e7ccc0b07..876c5db911 100644
--- a/Kconfig
+++ b/Kconfig
@@ -240,9 +240,25 @@  config PHYS_64BIT
 	  This can be used not only for 64bit SoCs, but also for
 	  large physical address extension on 32bit SoCs.
 
+config HAS_ROM
+	bool
+	select BINMAN
+	help
+	  Enables building of a u-boot.rom target. This collects U-Boot and
+	  any necessary binary blobs.
+
+config ROM_NEEDS_BLOBS
+	bool
+	depends on HAS_ROM
+	help
+	  Enable this if building the u-boot.rom target needs binary blobs, and
+	  so cannot be done normally. In this case, pass BUILD_ROM=1 to make
+	  to tell U-Boot to build the ROM.
+
 config BUILD_ROM
 	bool "Build U-Boot as BIOS replacement"
-	depends on X86
+	depends on HAS_ROM
+	default y if !ROM_NEEDS_BLOBS
 	help
 	  This option allows to build a ROM version of U-Boot.
 	  The build process generally requires several binary blobs
diff --git a/Makefile b/Makefile
index 149f839948..8a2bb94f2c 100644
--- a/Makefile
+++ b/Makefile
@@ -916,9 +916,12 @@  ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
 ALL-$(CONFIG_EFI_APP) += u-boot-app.efi
 ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
 
+ifneq ($(CONFIG_HAS_ROM),)
 ifneq ($(BUILD_ROM)$(CONFIG_BUILD_ROM),)
-ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
+ALL-y += u-boot.rom
 endif
+endif
+
 ifeq ($(CONFIG_SYS_COREBOOT)$(CONFIG_SPL),yy)
 ALL-$(CONFIG_BINMAN) += u-boot-x86-with-spl.bin
 endif
@@ -1580,7 +1583,7 @@  endif
 # 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_X86_RESET_VECTOR),)
+ifneq ($(CONFIG_HAS_ROM),)
 rom: u-boot.rom FORCE
 
 refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE
@@ -1590,11 +1593,12 @@  quiet_cmd_ldr = LD      $@
 cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
 	       $(filter-out FORCE,$^) -o $@
 
-u-boot.rom: u-boot-x86-start16.bin u-boot-x86-reset16.bin u-boot.bin \
+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) FORCE
-	$(call if_changed,binman)
+		$(if $(CONFIG_HAVE_REFCODE),refcode.bin)
 
 OBJCOPYFLAGS_u-boot-x86-start16.bin := -O binary -j .start16
 u-boot-x86-start16.bin: u-boot FORCE
@@ -1605,6 +1609,10 @@  u-boot-x86-reset16.bin: u-boot FORCE
 	$(call if_changed,objcopy)
 endif
 
+u-boot.rom: $(rom-deps) FORCE
+	$(call if_changed,binman)
+endif
+
 ifneq ($(CONFIG_ARCH_SUNXI),)
 ifeq ($(CONFIG_ARM64),)
 u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
diff --git a/arch/Kconfig b/arch/Kconfig
index a11f872938..ff417d40fd 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -160,6 +160,7 @@  config X86
 	select TIMER
 	select USE_PRIVATE_LIBGCC
 	select X86_TSC_TIMER
+	imply HAS_ROM if X86_RESET_VECTOR
 	imply BLK
 	imply CMD_DM
 	imply CMD_FPGA_LOADMK
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c8eae24c07..c688c46475 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -360,6 +360,8 @@  config HAVE_FSP
 	bool "Add an Firmware Support Package binary"
 	depends on !EFI
 	select USE_HOB
+	select HAS_ROM
+	select ROM_NEEDS_BLOBS
 	help
 	  Select this option to add an Firmware Support Package binary to
 	  the resulting U-Boot image. It is a binary blob which U-Boot uses
@@ -519,6 +521,8 @@  config ENABLE_MRC_CACHE
 
 config HAVE_MRC
 	bool "Add a System Agent binary"
+	select HAS_ROM
+	select ROM_NEEDS_BLOBS
 	depends on !HAVE_FSP
 	help
 	  Select this option to add a System Agent binary to
diff --git a/arch/x86/cpu/baytrail/Kconfig b/arch/x86/cpu/baytrail/Kconfig
index d2c3473d6a..53d945e931 100644
--- a/arch/x86/cpu/baytrail/Kconfig
+++ b/arch/x86/cpu/baytrail/Kconfig
@@ -7,6 +7,7 @@  config INTEL_BAYTRAIL
 	select HAVE_FSP
 	select ARCH_MISC_INIT
 	select CPU_INTEL_TURBO_NOT_PACKAGE_SCOPED
+	imply ROM_NEEDS_BLOBS
 	imply HAVE_INTEL_ME
 	imply ENABLE_MRC_CACHE
 	imply AHCI_PCI
diff --git a/arch/x86/cpu/quark/Kconfig b/arch/x86/cpu/quark/Kconfig
index 430cce184d..2fee38aed7 100644
--- a/arch/x86/cpu/quark/Kconfig
+++ b/arch/x86/cpu/quark/Kconfig
@@ -24,6 +24,7 @@  if INTEL_QUARK
 
 config HAVE_RMU
 	bool "Add a Remote Management Unit (RMU) binary"
+	select ROM_NEEDS_BLOBS
 	help
 	  Select this option to add a Remote Management Unit (RMU) binary
 	  to the resulting U-Boot image. It is a data block (up to 64K) of