From 41fdfae064f9c5934af83f5c76a95d1e0c910d76 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 2 Feb 2024 13:04:03 -0300 Subject: [PATCH] mx6sabresd: Fix U-Boot corruption after saving the environment U-Boot binary has grown in such a way that it goes beyond the reserved area for the environment variables. Running "saveenv" and rebooting the board causes U-Boot to hang because of this overlap. Fix this problem by selecting CONFIG_LTO so that the U-Boot proper size can be reduced. Also, to prevent this same problem to happen in the future, use CONFIG_BOARD_SIZE_LIMIT, which can detect the overlap in build-time. CONFIG_BOARD_SIZE_LIMIT is calculated as follows: CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot-img.dtb offset CONFIG_BOARD_SIZE_LIMIT = 0xc000 - 69 * 1024 CONFIG_BOARD_SIZE_LIMIT = 715766 Signed-off-by: Fabio Estevam Reviewed-by: Tom Rini Reviewed-by: Igor Opaniuk --- configs/mx6sabresd_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig index a90efe4a77..d4fb55622c 100644 --- a/configs/mx6sabresd_defconfig +++ b/configs/mx6sabresd_defconfig @@ -21,6 +21,9 @@ CONFIG_SPL_SERIAL=y CONFIG_SPL=y CONFIG_SPL_LIBDISK_SUPPORT=y CONFIG_PCI=y +CONFIG_LTO=y +CONFIG_HAS_BOARD_SIZE_LIMIT=y +CONFIG_BOARD_SIZE_LIMIT=715766 CONFIG_FIT=y CONFIG_SPL_FIT_PRINT=y CONFIG_SPL_LOAD_FIT=y -- 2.39.5