aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger2010-10-13 21:58:23 -0500
committerWolfgang Denk2010-10-19 16:28:53 -0500
commitf3a14d377e2fb4e48026810fbf67e189a5e5f515 (patch)
treebbc7fb26277b62bd6bd2dd9bcb1fe3f6c4025902 /Makefile
parente9319f111d366294b9a1e8b1f66875242a5de3dd (diff)
downloadu-boot-f3a14d377e2fb4e48026810fbf67e189a5e5f515.tar.gz
u-boot-f3a14d377e2fb4e48026810fbf67e189a5e5f515.tar.xz
u-boot-f3a14d377e2fb4e48026810fbf67e189a5e5f515.zip
Makefile: allow boards to check file size limits
Boards often have a reserved size limit on the flash where they're stored. Sometimes during upgrades or config changes, those limits are exceeded, but no one notices until they try to upgrade and the limit screws things up. Either not enough of U-Boot is written to flash (and so the reboot fails), or too much is written (and so things after it get clobbered). So allow boards to declare a size limit (in bytes) and have the build system check it while building. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 17 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 30a564d3cb..e9c069d3fa 100644
--- a/Makefile
+++ b/Makefile
@@ -304,6 +304,21 @@ __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
304######################################################################### 304#########################################################################
305######################################################################### 305#########################################################################
306 306
307ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
308BOARD_SIZE_CHECK = \
309 @actual=`wc -c $@ | awk '{print $$1}'`; \
310 limit=$(CONFIG_BOARD_SIZE_LIMIT); \
311 if test $$actual -gt $$limit; then \
312 echo "$@ exceeds file size limit:"; \
313 echo " limit: $$limit bytes"; \
314 echo " actual: $$actual bytes"; \
315 echo " excess: $$((actual - limit)) bytes"; \
316 exit 1; \
317 fi
318else
319BOARD_SIZE_CHECK =
320endif
321
307# Always append ALL so that arch config.mk's can add custom ones 322# Always append ALL so that arch config.mk's can add custom ones
308ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BOOT_ONENAND) 323ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BOOT_ONENAND)
309 324
@@ -317,10 +332,12 @@ $(obj)u-boot.srec: $(obj)u-boot
317 332
318$(obj)u-boot.bin: $(obj)u-boot 333$(obj)u-boot.bin: $(obj)u-boot
319 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ 334 $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
335 $(BOARD_SIZE_CHECK)
320 336
321$(obj)u-boot.ldr: $(obj)u-boot 337$(obj)u-boot.ldr: $(obj)u-boot
322 $(CREATE_LDR_ENV) 338 $(CREATE_LDR_ENV)
323 $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS) 339 $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
340 $(BOARD_SIZE_CHECK)
324 341
325$(obj)u-boot.ldr.hex: $(obj)u-boot.ldr 342$(obj)u-boot.ldr.hex: $(obj)u-boot.ldr
326 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary 343 $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary