From: Philip Oberfichtner <pro@denx.de>
To: u-boot@lists.denx.de
Cc: Philip Oberfichtner <pro@denx.de>,
Andre Przywara <andre.przywara@arm.com>,
Anshul Dalal <anshuld@ti.com>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Greg Malysa <malysagreg@gmail.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Jerome Forissier <jerome.forissier@linaro.org>,
Marek Vasut <marex@denx.de>,
Nathan Barrett-Morrison <nathan.morrison@timesys.com>,
Oliver Gaskell <Oliver.Gaskell@analog.com>,
Paul Kocialkowski <contact@paulk.fr>, Peng Fan <peng.fan@nxp.com>,
Peter Robinson <pbrobinson@gmail.com>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v5 1/4] Makefile: Simplify size check
Date: Wed, 30 Jul 2025 14:38:30 +0200 [thread overview]
Message-ID: <20250730123833.249923-2-pro@denx.de> (raw)
In-Reply-To: <20250730123833.249923-1-pro@denx.de>
Deduplicate some redundancies within the SIZE_CHECK code in the toplevel
Makefile. No functional changes.
Signed-off-by: Philip Oberfichtner <pro@denx.de>
---
Notes:
Changes in v5:
- Fix for broken boards reported in v4
- See https://patchwork.ozlabs.org/project/uboot/patch/20250708103959.26129-2-pro@denx.de/
Makefile | 44 ++++++++++--------------------------------
tools/spl_size_limit.c | 2 +-
2 files changed, 11 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile
index c31bf7ecea9..aefa44c327f 100644
--- a/Makefile
+++ b/Makefile
@@ -432,7 +432,7 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
define size_check
actual=$$( wc -c $1 | awk '{print $$1}'); \
limit=$$( printf "%d" $2 ); \
- if test $$actual -gt $$limit; then \
+ if test $$limit -gt 0 && test $$actual -gt $$limit; then \
echo "$1 exceeds file size limit:" >&2; \
echo " limit: $$(printf %#x $$limit) bytes" >&2; \
echo " actual: $$(printf %#x $$actual) bytes" >&2; \
@@ -1103,30 +1103,6 @@ LDPPFLAGS += \
#########################################################################
#########################################################################
-ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
-BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
-else
-BOARD_SIZE_CHECK =
-endif
-
-ifneq ($(CONFIG_SPL_SIZE_LIMIT),0x0)
-SPL_SIZE_CHECK = @$(call size_check,$@,$$(tools/spl_size_limit))
-else
-SPL_SIZE_CHECK =
-endif
-
-ifneq ($(CONFIG_TPL_SIZE_LIMIT),0x0)
-TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))
-else
-TPL_SIZE_CHECK =
-endif
-
-ifneq ($(CONFIG_VPL_SIZE_LIMIT),0x0)
-VPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_VPL_SIZE_LIMIT))
-else
-VPL_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
@@ -1470,7 +1446,7 @@ endif
%.imx: $(IMX_DEPS) %.bin
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
- $(BOARD_SIZE_CHECK)
+ @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
%.vyb: %.imx
$(Q)$(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $@
@@ -1571,12 +1547,12 @@ endif
u-boot-nodtb.bin: u-boot FORCE
$(call if_changed,objcopy_uboot)
- $(BOARD_SIZE_CHECK)
+ @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
u-boot.ldr: u-boot
$(CREATE_LDR_ENV)
$(LDR) -T $(CONFIG_LDR_CPU) -c $@ $< $(LDR_FLAGS)
- $(BOARD_SIZE_CHECK)
+ @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
# binman
# ---------------------------------------------------------------------------
@@ -1703,7 +1679,7 @@ u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
,$(UBOOT_BIN)) FORCE
$(call if_changed,mkimage)
- $(BOARD_SIZE_CHECK)
+ @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
ifeq ($(CONFIG_SPL_LOAD_FIT_FULL),y)
MKIMAGEFLAGS_u-boot.itb =
@@ -1718,12 +1694,12 @@ u-boot.itb: u-boot-nodtb.bin \
$(if $(CONFIG_MULTI_DTB_FIT),$(FINAL_DTB_CONTAINER)) \
$(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
- $(BOARD_SIZE_CHECK)
+ @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
endif
u-boot-with-spl.kwb: u-boot.bin spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
- $(BOARD_SIZE_CHECK)
+ @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
u-boot.dis: u-boot
$(OBJDUMP) -d $< > $@
@@ -2342,7 +2318,7 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
spl/u-boot-spl.bin: spl/u-boot-spl
@:
- $(SPL_SIZE_CHECK)
+ @$(call size_check,$@,$$(tools/spl_size_limit))
spl/u-boot-spl-dtb.bin: spl/u-boot-spl
@:
@@ -2367,14 +2343,14 @@ spl/boot.bin: spl/u-boot-spl
tpl/u-boot-tpl.bin: tpl/u-boot-tpl
@:
- $(TPL_SIZE_CHECK)
+ @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))
tpl/u-boot-tpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.xpl all
vpl/u-boot-vpl.bin: vpl/u-boot-vpl
@:
- $(VPL_SIZE_CHECK)
+ @$(call size_check,$@,$(CONFIG_VPL_SIZE_LIMIT))
vpl/u-boot-vpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
$(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.xpl all
diff --git a/tools/spl_size_limit.c b/tools/spl_size_limit.c
index c6c139e834f..137f0fca898 100644
--- a/tools/spl_size_limit.c
+++ b/tools/spl_size_limit.c
@@ -28,6 +28,6 @@ int main(int argc, char *argv[])
#endif
#endif
- printf("%d", spl_size_limit);
+ printf("%d", spl_size_limit > 0 ? spl_size_limit : 0);
return 0;
}
--
2.39.5
next prev parent reply other threads:[~2025-07-30 12:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 12:38 [PATCH v5 0/4] Add Onion Omega2/2+ board support Philip Oberfichtner
2025-07-30 12:38 ` Philip Oberfichtner [this message]
2025-07-31 16:05 ` [PATCH v5 1/4] Makefile: Simplify size check Tom Rini
2025-07-30 12:38 ` [PATCH v5 2/4] Makefile: Add size check for u-boot-with-spl.bin Philip Oberfichtner
2025-07-31 16:05 ` Tom Rini
2025-07-30 12:38 ` [PATCH v5 3/4] mips: serial: Silence "unused variable" warning Philip Oberfichtner
2025-07-30 12:38 ` [PATCH v5 4/4] mips: mt7628: Add Onion Omega2/2+ board support Philip Oberfichtner
2025-08-04 15:02 ` Daniel Schwierzeck
2025-08-07 7:59 ` Philip Oberfichtner
2025-08-04 10:00 ` [PATCH v5 0/4] " Philip Oberfichtner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250730123833.249923-2-pro@denx.de \
--to=pro@denx.de \
--cc=Oliver.Gaskell@analog.com \
--cc=andre.przywara@arm.com \
--cc=anshuld@ti.com \
--cc=contact@paulk.fr \
--cc=dario.binacchi@amarulasolutions.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jerome.forissier@linaro.org \
--cc=malysagreg@gmail.com \
--cc=marex@denx.de \
--cc=nathan.morrison@timesys.com \
--cc=pbrobinson@gmail.com \
--cc=peng.fan@nxp.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.