mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-03-17 15:27:00 +00:00
Merge branch '2019-06-07-master-imports'
- Include Heinrich's series to move the i.MX board size check function to be more widely available. - Include Simon Goldschmidt's patch to make it possible to have a more accurate SPL size check applied.
This commit is contained in:
commit
a56149dd97
6 changed files with 95 additions and 26 deletions
34
Makefile
34
Makefile
|
@ -337,6 +337,19 @@ endif
|
|||
# KBUILD_MODULES := 1
|
||||
#endif
|
||||
|
||||
define size_check
|
||||
actual=$$( wc -c $1 | awk '{print $$1}'); \
|
||||
limit=$$( printf "%d" $2 ); \
|
||||
if test $$actual -gt $$limit; then \
|
||||
echo "$1 exceeds file size limit:" >&2; \
|
||||
echo " limit: $$limit bytes" >&2; \
|
||||
echo " actual: $$actual bytes" >&2; \
|
||||
echo " excess: $$((actual - limit)) bytes" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
endef
|
||||
export size_check
|
||||
|
||||
export KBUILD_MODULES KBUILD_BUILTIN
|
||||
export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
|
||||
|
||||
|
@ -778,20 +791,17 @@ LDPPFLAGS += \
|
|||
#########################################################################
|
||||
|
||||
ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
|
||||
BOARD_SIZE_CHECK = \
|
||||
@actual=`wc -c $@ | awk '{print $$1}'`; \
|
||||
limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
|
||||
if test $$actual -gt $$limit; then \
|
||||
echo "$@ exceeds file size limit:" >&2 ; \
|
||||
echo " limit: $$limit bytes" >&2 ; \
|
||||
echo " actual: $$actual bytes" >&2 ; \
|
||||
echo " excess: $$((actual - limit)) bytes" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
|
||||
else
|
||||
BOARD_SIZE_CHECK =
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_SPL_SIZE_LIMIT),0)
|
||||
SPL_SIZE_CHECK = @$(call size_check,$@,$$(tools/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
|
||||
|
@ -1090,6 +1100,7 @@ endif
|
|||
|
||||
%.imx: %.bin
|
||||
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
|
||||
$(BOARD_SIZE_CHECK)
|
||||
|
||||
%.vyb: %.imx
|
||||
$(Q)$(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $@
|
||||
|
@ -1707,6 +1718,8 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
|
|||
|
||||
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)
|
||||
|
@ -1769,6 +1782,7 @@ checkarmreloc: u-boot
|
|||
envtools: scripts_basic $(version_h) $(timestamp_h)
|
||||
$(Q)$(MAKE) $(build)=tools/env
|
||||
|
||||
tools-only: export TOOLS_ONLY=y
|
||||
tools-only: scripts_basic $(version_h) $(timestamp_h)
|
||||
$(Q)$(MAKE) $(build)=tools
|
||||
|
||||
|
|
|
@ -61,21 +61,6 @@ obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
|
|||
obj-$(CONFIG_CMD_DEKBLOB) += cmd_dek.o
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
|
||||
BOARD_SIZE_CHECK = \
|
||||
@actual=`wc -c $@ | awk '{print $$1}'`; \
|
||||
limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
|
||||
if test $$actual -gt $$limit; then \
|
||||
echo "$@ exceeds file size limit:" >&2 ; \
|
||||
echo " limit: $$limit bytes" >&2 ; \
|
||||
echo " actual: $$actual bytes" >&2 ; \
|
||||
echo " excess: $$((actual - limit)) bytes" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
else
|
||||
BOARD_SIZE_CHECK =
|
||||
endif
|
||||
|
||||
PLUGIN = board/$(BOARDDIR)/plugin
|
||||
|
||||
ifeq ($(CONFIG_USE_IMXIMG_PLUGIN),y)
|
||||
|
@ -124,7 +109,6 @@ u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
|
|||
|
||||
u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
|
||||
$(call if_changed,mkimage)
|
||||
$(BOARD_SIZE_CHECK)
|
||||
|
||||
ifeq ($(CONFIG_OF_SEPARATE),y)
|
||||
MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
|
||||
|
|
|
@ -25,6 +25,42 @@ config SPL_FRAMEWORK
|
|||
supports MMC, NAND and YMODEM and other methods loading of U-Boot
|
||||
and the Linux Kernel. If unsure, say Y.
|
||||
|
||||
config SPL_SIZE_LIMIT
|
||||
hex "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.
|
||||
|
||||
config SPL_SIZE_LIMIT_SUBTRACT_GD
|
||||
bool "SPL image size check: provide space for global data"
|
||||
depends on SPL_SIZE_LIMIT > 0
|
||||
help
|
||||
If enabled, aligned size of global data is reserved in
|
||||
SPL_SIZE_LIMIT check to ensure such an image does not overflow SRAM
|
||||
if SPL_SIZE_LIMIT describes the size of SRAM available for SPL when
|
||||
pre-reloc global data is put into this SRAM, too.
|
||||
|
||||
config SPL_SIZE_LIMIT_SUBTRACT_MALLOC
|
||||
bool "SPL image size check: provide space for malloc() pool before relocation"
|
||||
depends on SPL_SIZE_LIMIT > 0
|
||||
help
|
||||
If enabled, SPL_SYS_MALLOC_F_LEN is reserved in SPL_SIZE_LIMIT check
|
||||
to ensure such an image does not overflow SRAM if SPL_SIZE_LIMIT
|
||||
describes the size of SRAM available for SPL when pre-reloc malloc
|
||||
pool is put into this SRAM, too.
|
||||
|
||||
config SPL_SIZE_LIMIT_PROVIDE_STACK
|
||||
hex "SPL image size check: provide stack space before relocation"
|
||||
depends on SPL_SIZE_LIMIT > 0
|
||||
default 0
|
||||
help
|
||||
If set, this size is reserved in SPL_SIZE_LIMIT check to ensure such
|
||||
an image does not overflow SRAM if SPL_SIZE_LIMIT describes the size
|
||||
of SRAM available for SPL when the stack required before reolcation
|
||||
uses this SRAM, too.
|
||||
|
||||
config HANDOFF
|
||||
bool "Pass hand-off information from SPL to U-Boot proper"
|
||||
depends on BLOBLIST
|
||||
|
|
|
@ -3,6 +3,7 @@ CONFIG_ARCH_ROCKCHIP=y
|
|||
CONFIG_SYS_TEXT_BASE=0x00000000
|
||||
CONFIG_SYS_MALLOC_F_LEN=0x2000
|
||||
CONFIG_ROCKCHIP_RK3288=y
|
||||
CONFIG_SPL_SIZE_LIMIT=30720
|
||||
CONFIG_SPL_ROCKCHIP_BACK_TO_BROM=y
|
||||
CONFIG_TARGET_TINKER_RK3288=y
|
||||
CONFIG_NR_DRAM_BANKS=1
|
||||
|
|
|
@ -199,6 +199,10 @@ hostprogs-$(CONFIG_RISCV) += prelink-riscv
|
|||
hostprogs-y += fdtgrep
|
||||
fdtgrep-objs += $(LIBFDT_OBJS) fdtgrep.o
|
||||
|
||||
ifneq ($(TOOLS_ONLY),y)
|
||||
hostprogs-y += spl_size_limit
|
||||
endif
|
||||
|
||||
hostprogs-$(CONFIG_MIPS) += mips-relocs
|
||||
|
||||
# We build some files with extra pedantic flags to try to minimize things
|
||||
|
|
30
tools/spl_size_limit.c
Normal file
30
tools/spl_size_limit.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (c) 2019, Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
|
||||
*
|
||||
* This tool helps to return the size available for SPL image during build
|
||||
*/
|
||||
|
||||
#include <generated/autoconf.h>
|
||||
#include <generated/generic-asm-offsets.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int spl_size_limit = 0;
|
||||
|
||||
#ifdef CONFIG_SPL_SIZE_LIMIT
|
||||
spl_size_limit = CONFIG_SPL_SIZE_LIMIT;
|
||||
#ifdef CONFIG_SPL_SIZE_LIMIT_SUBTRACT_GD
|
||||
spl_size_limit -= GENERATED_GBL_DATA_SIZE;
|
||||
#endif
|
||||
#ifdef CONFIG_SPL_SIZE_LIMIT_SUBTRACT_MALLOC
|
||||
spl_size_limit -= CONFIG_SPL_SYS_MALLOC_F_LEN;
|
||||
#endif
|
||||
#ifdef CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK
|
||||
spl_size_limit -= CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
printf("%d", spl_size_limit);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue