u-boot-brain/tools/spl_size_limit.c
Breno Matheus Lima 7171437166 imx6: spl: Reduce SPL limit size in case CONFIG_SECURE_BOOT is enabled
In case CONFIG_SECURE_BOOT is enabled we need to limit the SPL size to
avoid a possible HAB failure event:

--------- HAB Event 1 -----------------
event data:
        0xdb 0x00 0x14 0x42 0x33 0x22 0x33 0x00
        0x00 0x00 0x00 0x0f 0x00 0x90 0x70 0x00
        0x00 0x01 0x10 0x00
STS = HAB_FAILURE (0x33)
RSN = HAB_INV_ADDRESS (0x22)
CTX = HAB_CTX_TARGET (0x33)
ENG = HAB_ENG_ANY (0x00)

As explained in Commit 23612534fe ("spl: imx6: Provide a SPL_SIZE_LIMIT
default") the i.MX6 SPL size limit is 68KB.

The ROM code is copying the image size defined in boot data to its
respective load address, in case we exceed the OCRAM free region a
HAB invalid address failure event is generated.

The maximum CSF size is defined in CONFIG_CSF_SIZE, reduce SPL size
limit based on this configuration.

Signed-off-by: Breno Lima <breno.lima@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
2019-10-08 16:35:58 +02:00

34 lines
858 B
C

// 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;
#if defined(CONFIG_SECURE_BOOT) && defined(CONFIG_CSF_SIZE)
spl_size_limit -= CONFIG_CSF_SIZE;
#endif
#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;
}