[RFC PATCH v1 3/3] Image size checks: Move all configs in one place
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Thu Jul 31 14:14:08 CEST 2025
On 31.07.25 13:40, Philip Oberfichtner wrote:
> How image size limiting works in U-Boot should be easier to grasp if we
> have all related options in one place.
>
> Signed-off-by: Philip Oberfichtner <pro at denx.de>
> ---
> Kconfig | 59 ++++++++++++++++++++++++++++++++++++++++++
> common/spl/Kconfig | 38 ---------------------------
> common/spl/Kconfig.tpl | 7 -----
> common/spl/Kconfig.vpl | 7 -----
> 4 files changed, 59 insertions(+), 52 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index d0c0a6a1d53..6435a4c3bcc 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -535,6 +535,8 @@ config BUILD_TARGET
> special image will be automatically built upon calling
> make / buildman.
>
> +menu "Image size limits"
> +
> config BOARD_SIZE_LIMIT
> int "Maximum size of the U-Boot image in bytes"
> default 0
> @@ -546,6 +548,63 @@ config BOARD_SIZE_LIMIT
> include SPL nor TPL, on platforms that use that functionality, they
> have a separate option to restict size.
When reposting, please, rebase on by patch to fix the 'restict' typo.
>
> +config SPL_SIZE_LIMIT
> + depends on SPL
> + hex "Maximum size of SPL image"
> + default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> + default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
This can be simplified:
default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
default 0x11000 if ARCH_MX6
Best regards
Heinrich
> + default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> + default 0x0
> + 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 0x0
> + 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 TPL_SIZE_LIMIT
> + depends on TPL
> + hex "Maximum size of TPL image"
> + default 0x0
> + help
> + Specifies the maximum length of the U-Boot TPL image.
> + If this value is zero, it is ignored.
> +
> +config VPL_SIZE_LIMIT
> + depends on VPL
> + hex "Maximum size of VPL image"
> + default 0x0
> + help
> + Specifies the maximum length of the U-Boot VPL image.
> + If this value is zero, it is ignored.
> +
> +endmenu
> +
> config SYS_CUSTOM_LDSCRIPT
> bool "Use a custom location for the U-Boot linker script"
> depends on !COMPILE_TEST
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index ab05536bd02..87a56bd8f8a 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -36,44 +36,6 @@ config SPL_FRAMEWORK_BOARD_INIT_F
> - initialize the serial (preloader_console_init)
> Unless you want to provide your own board_init_f, you should say Y.
>
> -config SPL_SIZE_LIMIT
> - hex "Maximum size of SPL image"
> - default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> - default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> - default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> - default 0x0
> - 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 0x0
> - 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 SPL_MAX_SIZE
> hex "Maximum size of the SPL image, excluding BSS"
> default 0x30000 if ARCH_MX6 && MX6_OCRAM_256KB
> diff --git a/common/spl/Kconfig.tpl b/common/spl/Kconfig.tpl
> index a535b61ecd3..515bbeec685 100644
> --- a/common/spl/Kconfig.tpl
> +++ b/common/spl/Kconfig.tpl
> @@ -1,13 +1,6 @@
> menu "TPL configuration options"
> depends on TPL
>
> -config TPL_SIZE_LIMIT
> - hex "Maximum size of TPL image"
> - default 0x0
> - help
> - Specifies the maximum length of the U-Boot TPL image.
> - If this value is zero, it is ignored.
> -
> config TPL_BINMAN_SYMBOLS
> bool "Support binman symbols in TPL"
> depends on TPL_FRAMEWORK && BINMAN
> diff --git a/common/spl/Kconfig.vpl b/common/spl/Kconfig.vpl
> index 434562443ac..739f2805315 100644
> --- a/common/spl/Kconfig.vpl
> +++ b/common/spl/Kconfig.vpl
> @@ -220,13 +220,6 @@ config VPL_SERIAL
> Enable support for serial in VPL. See SPL_SERIAL for
> details.
>
> -config VPL_SIZE_LIMIT
> - hex "Maximum size of VPL image"
> - default 0x0
> - help
> - Specifies the maximum length of the U-Boot VPL image.
> - If this value is zero, it is ignored.
> -
> config VPL_SPI
> bool "Support SPI drivers"
> help
More information about the U-Boot
mailing list