diff options
Diffstat (limited to 'common/spl')
-rw-r--r-- | common/spl/Kconfig | 19 | ||||
-rw-r--r-- | common/spl/spl.c | 25 | ||||
-rw-r--r-- | common/spl/spl_dfu.c | 4 | ||||
-rw-r--r-- | common/spl/spl_ext.c | 1 | ||||
-rw-r--r-- | common/spl/spl_fat.c | 1 | ||||
-rw-r--r-- | common/spl/spl_fit.c | 1 | ||||
-rw-r--r-- | common/spl/spl_net.c | 1 | ||||
-rw-r--r-- | common/spl/spl_ymodem.c | 1 |
8 files changed, 51 insertions, 2 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 54154b93c9..630491699c 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -62,6 +62,25 @@ config SPL_SIZE_LIMIT_PROVIDE_STACK of SRAM available for SPL when the stack required before reolcation uses this SRAM, too. +config SPL_SYS_STACK_F_CHECK_BYTE + hex + default 0xaa + help + Constant used to check the stack + +config SPL_SYS_REPORT_STACK_F_USAGE + depends on SPL_SIZE_LIMIT_PROVIDE_STACK != 0 + bool "Check and report stack usage in SPL before relocation" + help + If this option is enabled, the initial SPL stack is filled with 0xaa + very early, up to the size configured with + SPL_SIZE_LIMIT_PROVIDE_STACK. + Later when SPL is done using this initial stack and switches to a + stack in DRAM, the actually used size of this initial stack is + reported by examining the memory and searching for the lowest + occurrence of non 0xaa bytes. + This default implementation works for stacks growing down only. + menu "PowerPC SPL Boot options" depends on PPC && (SUPPORT_SPL && !SPL_FRAMEWORK) diff --git a/common/spl/spl.c b/common/spl/spl.c index c182705b3f..2c696f2a79 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -710,6 +710,28 @@ void preloader_console_init(void) #endif /** + * This function is called before the stack is changed from initial stack to + * relocated stack. It tries to dump the stack size used + */ +__weak void spl_relocate_stack_check(void) +{ +#if CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE) + ulong init_sp = gd->start_addr_sp; + ulong stack_bottom = init_sp - CONFIG_VAL(SIZE_LIMIT_PROVIDE_STACK); + u8 *ptr = (u8 *)stack_bottom; + ulong i; + + for (i = 0; i < CONFIG_VAL(SIZE_LIMIT_PROVIDE_STACK); i++) { + if (*ptr != CONFIG_VAL(SYS_STACK_F_CHECK_BYTE)) + break; + ptr++; + } + printf("SPL initial stack usage: %lu bytes\n", + CONFIG_VAL(SIZE_LIMIT_PROVIDE_STACK) - i); +#endif +} + +/** * spl_relocate_stack_gd() - Relocate stack ready for board_init_r() execution * * Sometimes board_init_f() runs with a stack in SRAM but we want to use SDRAM @@ -733,6 +755,9 @@ ulong spl_relocate_stack_gd(void) gd_t *new_gd; ulong ptr = CONFIG_SPL_STACK_R_ADDR; + if (CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE)) + spl_relocate_stack_check(); + #if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_VAL(SYS_MALLOC_F_LEN) if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) { debug("SPL malloc() before relocation used 0x%lx bytes (%ld KB)\n", diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c index c0225dc4e1..5728d43ad3 100644 --- a/common/spl/spl_dfu.c +++ b/common/spl/spl_dfu.c @@ -6,6 +6,7 @@ * Ravi B <ravibabu@ti.com> */ #include <common.h> +#include <env.h> #include <spl.h> #include <linux/compiler.h> #include <errno.h> @@ -14,7 +15,6 @@ #include <g_dnl.h> #include <usb.h> #include <dfu.h> -#include <environment.h> static int run_dfu(int usb_index, char *interface, char *devstring) { @@ -38,7 +38,7 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr) int ret; /* set default environment */ - set_default_env(NULL, 0); + env_set_default(NULL, 0); str_env = env_get(dfu_alt_info); if (!str_env) { pr_err("\"%s\" env variable not defined!\n", dfu_alt_info); diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c index fe05223605..2a6252229c 100644 --- a/common/spl/spl_ext.c +++ b/common/spl/spl_ext.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include <common.h> +#include <env.h> #include <spl.h> #include <asm/u-boot.h> #include <ext4fs.h> diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index 163e540622..aa371ab52c 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -9,6 +9,7 @@ */ #include <common.h> +#include <env.h> #include <spl.h> #include <asm/u-boot.h> #include <fat.h> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 969f7775c1..2e2e09eafb 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -7,6 +7,7 @@ #include <common.h> #include <errno.h> #include <fpga.h> +#include <gzip.h> #include <image.h> #include <linux/libfdt.h> #include <spl.h> diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c index c91ad2b6dd..803303249c 100644 --- a/common/spl/spl_net.c +++ b/common/spl/spl_net.c @@ -7,6 +7,7 @@ * Ilya Yanok <ilya.yanok@gmail.com> */ #include <common.h> +#include <env.h> #include <errno.h> #include <spl.h> #include <net.h> diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index fa539ecd7a..20f4260062 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -9,6 +9,7 @@ * Matt Porter <mporter@ti.com> */ #include <common.h> +#include <gzip.h> #include <spl.h> #include <xyzModem.h> #include <asm/u-boot.h> |