diff options
author | Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> | 2019-05-24 22:07:04 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-06-07 11:03:39 -0400 |
commit | 2577015dc5c48e7892dea8731a27530543606673 (patch) | |
tree | fbc3cff0721a1be36cb343b841ad7374e33606fb /tools/spl_size_limit.c | |
parent | dfe252b11e23e9aa54e87aadc8d8ac5c1ab56861 (diff) | |
download | u-boot-2577015dc5c48e7892dea8731a27530543606673.tar.gz |
spl: add overall SPL size check
This adds a size check for SPL that can dynamically check generated
SPL binaries (including devicetree) for a size limit that ensures
this image plus global data, heap and stack fit in initial SRAM.
Since some of these sizes are not available to make, a new host tool
'spl_size_limit' is added that dumps the resulting maximum size for
an SPL binary to stdout. This tool is used in toplevel Makefile to
implement the size check on SPL binaries.
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Diffstat (limited to 'tools/spl_size_limit.c')
-rw-r--r-- | tools/spl_size_limit.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/spl_size_limit.c b/tools/spl_size_limit.c new file mode 100644 index 0000000000..98ff491867 --- /dev/null +++ b/tools/spl_size_limit.c @@ -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; +} |