configs: define CONFIG_SPL_SIZE_LIMIT
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 2 Apr 2019 17:19:06 +0000 (19:19 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 7 Jun 2019 15:03:39 +0000 (11:03 -0400)
A new configuration variable CONFIG_SPL_SIZE_LIMIT is introduced to define
the board specific maximum size for the SPL file.

Use Makefile function size_check() to implement the test.

Depending on the size of CONFIG_SPL_SIZE_LIMIT an error like the following
is thrown:

spl/u-boot-spl.bin exceeds file size limit:
  limit:  30720 bytes
  actual: 33426 bytes
  excess: 2706 bytes
make: *** [Makefile:1663: spl/u-boot-spl.bin] Error 1

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Kconfig
Makefile

diff --git a/Kconfig b/Kconfig
index a021686..709912e 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -173,6 +173,14 @@ config TPL_SYS_MALLOC_F_LEN
          particular needs this to operate, so that it can allocate the
          initial serial device and any others that are needed.
 
          particular needs this to operate, so that it can allocate the
          initial serial device and any others that are needed.
 
+config SPL_SIZE_LIMIT
+       int "Maximum size of SPL image"
+       depends on SPL
+       default 0
+       help
+         Specifies the maximum length of the U-Boot SPL image.
+         If this value is zero, it is ignored.
+
 menuconfig EXPERT
        bool "Configure standard U-Boot features (expert users)"
        default y
 menuconfig EXPERT
        bool "Configure standard U-Boot features (expert users)"
        default y
index af2ab4e..da8a38d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -796,6 +796,12 @@ else
 BOARD_SIZE_CHECK =
 endif
 
 BOARD_SIZE_CHECK =
 endif
 
+ifneq ($(CONFIG_SPL_SIZE_LIMIT),0)
+SPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_SPL_SIZE_LIMIT))
+else
+SPL_SIZE_CHECK =
+endif
+
 # Statically apply RELA-style relocations (currently arm64 only)
 # This is useful for arm64 where static relocation needs to be performed on
 # the raw binary, but certain simulators only accept an ELF file (but don't
 # Statically apply RELA-style relocations (currently arm64 only)
 # This is useful for arm64 where static relocation needs to be performed on
 # the raw binary, but certain simulators only accept an ELF file (but don't
@@ -1712,6 +1718,8 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
 
 spl/u-boot-spl.bin: spl/u-boot-spl
        @:
 
 spl/u-boot-spl.bin: spl/u-boot-spl
        @:
+       $(SPL_SIZE_CHECK)
+
 spl/u-boot-spl: tools prepare \
                $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \
                $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)
 spl/u-boot-spl: tools prepare \
                $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \
                $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)