mx6sabresd: Reduce U-Boot proper size to fix boot regression
PATCH v2 1/1 mx6sabresd: Reduce U-Boot proper size to fix boot regression
The mx6sabresd U-Boot proper binary size has grown beyond the CONFIG_BOARD_SIZE_LIMIT.
Reduce its size by removing the CONFIG_MULTI_DTB_FIT, BOOTM_PLAN9 and BOOTM_RTEMS options.
According to doc/README.multi-dtb-fit:
"Usually the DTB is selected by the SPL and passed down to U-Boot. But some platforms don't use the SPL. In this case MULTI_DTB_FIT can used to provide U-Boot with a choice of DTBs"
mx6sabresd uses SPL, so MULTI_DTB_FIT can be safely dropped as the DTB selection in SPL is done by board_fit_config_name_match().
Tested boot on the imx6dl and imx6q variants.
--- configs/mx6sabresd_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
configs/mx6sabresd_defconfig +2 -1
@@ -40,6 +40,8 @@ CONFIG_SPL_WATCHDOG=y CONFIG_HUSH_PARSER=y CONFIG_SYS_MAXARGS=32 CONFIG_CMD_BOOTZ=y +# CONFIG_BOOTM_PLAN9 is not set +# CONFIG_BOOTM_RTEMS is not set CONFIG_CMD_SPL=y CONFIG_CMD_SPL_WRITE_SIZE=0x20000 CONFIG_CMD_GPIO=y
@@ -65,7 +67,6 @@ CONFIG_EFI_PARTITION=y # CONFIG_SPL_EFI_PARTITION is not set CONFIG_OF_CONTROL=y CONFIG_OF_LIST="imx6q-sabresd imx6qp-sabresd imx6dl-sabresd" -CONFIG_MULTI_DTB_FIT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y
Signature · 1 line
2.34.1
Hi Fabio,
Quoted 5 lines · Fabio Estevam
The mx6sabresd U-Boot proper binary size has grown beyond the
CONFIG_BOARD_SIZE_LIMIT.Reduce its size by removing the
CONFIG_MULTI_DTB_FIT,BOOTM_PLAN9andBOOTM_RTEMSoptions.
FWIW, I'm working on a better fix than commit 410d59095a9f ("arm: kirkwood:
fix freeze on boot") for the LTO link issue that appeared when I made the static initcalls series. Instead of disabling LTO for common/board_{f,r}.c I will instead move th e problematic inline assembly code to separate .S files. The idea is to get rid of the selective LTO disabling (there are others places which do that) and at the same time to not force -marm on some C files that could totally be compiled in Thumb/Thumb2 mode if it weren't for this inline assembly with mrc/mcr instructions. In other words, let the compiler and linker do their job. While it could cost a few bytes in some cases compared to inlining, I also expect meaningful reductions in other cases. It will all depend on arm vs. thumb and LTO vs. no LTO.
Anyway, I looked at the impact of my series on the binary size for mx6sabresd. Good news, it does save 1702 bytes:
$ git log --oneline -n 4 306a6f7adf8 (HEAD -> lto-fixes-tmp2) arm: do not force -marm on some C files and allow LTO everywhere 1680ed4cbb2 arm: move inline assembly CP15 instructions to separate .S files 018263f9278 Revert "arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set" 7027b445cc0 Merge tag 'efi-2025-07-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi $ tools/buildman/buildman -b lto-fixes-tmp2 -c 4 --step -0 mx6sabresd $ tools/buildman/buildman -b lto-fixes-tmp2 -c 4 --step 0 -sSd mx6sabresd Summary of 2 commits for 1 boards (1 thread, 24 jobs per thread) 01: Merge tag 'efi-2025-07-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi 04: arm: do not force -marm on some C files and allow LTO everywhere arm: (for 1/1 boards) all -1702.0 data -4.0 rodata -514.0 text -1184.0 mx6sabresd : all -1702 data -4 rodata -514 text -1184 (no errors to report)
So stay tuned for more on this. When the series is ready I will post it for review with a link to the buildman size stats for all plaforms. It should happen next week.
Regards,
Signature · 1 line
Jerome
Quoted 37 lines
According to doc/README.multi-dtb-fit:
"Usually the DTB is selected by the SPL and passed down to U-Boot. But some platforms don't use the SPL. In this case
MULTI_DTB_FITcan used to provide U-Boot with a choice of DTBs"mx6sabresd uses SPL, so
MULTI_DTB_FITcan be safely dropped as the DTB selection in SPL is done byboard_fit_config_name_match().Tested boot on the imx6dl and imx6q variants.
Signed-off-by Fabio Estevam <[email protected]>--- configs/mx6sabresd_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)configs/mx6sabresd_defconfig +2
-1@@ -40,6 +40,8 @@ CONFIG_SPL_WATCHDOG=y CONFIG_HUSH_PARSER=y CONFIG_SYS_MAXARGS=32 CONFIG_CMD_BOOTZ=y +# CONFIG_BOOTM_PLAN9 is not set +# CONFIG_BOOTM_RTEMS is not set CONFIG_CMD_SPL=y CONFIG_CMD_SPL_WRITE_SIZE=0x20000 CONFIG_CMD_GPIO=y@@ -65,7 +67,6 @@ CONFIG_EFI_PARTITION=y # CONFIG_SPL_EFI_PARTITION is not set CONFIG_OF_CONTROL=y CONFIG_OF_LIST="imx6q-sabresd imx6qp-sabresd imx6dl-sabresd" -CONFIG_MULTI_DTB_FIT=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y
Quoted 2 lines · Fabio Estevam
The mx6sabresd U-Boot proper binary size has grown beyond the
CONFIG_BOARD_SIZE_LIMIT.
So, is CONFIG_BOARD_SIZE_LIMIT set incorrectly then and needs to be lowered?
Signature · 1 line
Tom
Quoted 8 lines · Tom Rini
Quoted 2 lines · Fabio Estevam
The mx6sabresd U-Boot proper binary size has grown beyond the
CONFIG_BOARD_SIZE_LIMIT.So, is
CONFIG_BOARD_SIZE_LIMITset incorrectly then and needs to be lowered?
The current CONFIG_BOARD_SIZE_LIMIT is 715766.
This value is CONFIG_ENV_OFFSET (0xC0000) - the offset for U-Boot proper (69k) = 786432 − 69×1024 = 715776.
The calculation itself is correct.
The first issue: CI does not report a build failure. However, my local build reports:
u-boot.img exceeds file size limit:
limit: 0xaebf6 bytes
actual: 0xaed70 bytes
excess: 0x17a bytes
make: *** [Makefile:1501: u-boot.img] Error 1
make: *** Deleting file 'u-boot.img'
make: *** Waiting for unfinished jobs....
u-boot-dtb.img exceeds file size limit:
limit: 0xaebf6 bytes
actual: 0xaed70 bytes
excess: 0x17a bytes
make: *** [Makefile:1501: u-boot-dtb.img] Error 1
make: *** Deleting file 'u-boot-dtb.img'
The second issue is that even if I remove the CONFIG_HAS_BOARD_SIZE_LIMIT/CONFIG_BOARD_SIZE_LIMIT, it builds, but fails to boot like this:
U-Boot SPL 2025.07-rc5-00012-g7027b445cc0b-dirty (Jul 04 2025 - 13:22:16 -0300) Trying to boot from MMC1
This boot failure is related to the initcall series.
To avoid the mx6abresd boot regression and play safe for the upcoming 2025.07, I'm more inclined to go with the previous patch version that increases CONFIG_BOARD_SIZE_LIMIT.
Jerome said he is working on a better fix, which reduces the size by 1702 bytes for sabresd.
Having CONFIG_BOARD_SIZE_LIMIT with too low a headroom may cause a problem where, on some build systems, such as U-Boot CI, the build succeeds, while others, like my local build, fail.
Let's provide more CONFIG_BOARD_SIZE_LIMIT headroom to avoid this situation from happening again.
If you agree, feel free to pick v1.
Thanks
Quoted 34 lines · Fabio Estevam
Quoted 8 lines · Tom Rini
Quoted 2 lines · Fabio Estevam
The mx6sabresd U-Boot proper binary size has grown beyond the
CONFIG_BOARD_SIZE_LIMIT.So, is
CONFIG_BOARD_SIZE_LIMITset incorrectly then and needs to be lowered?The current
CONFIG_BOARD_SIZE_LIMITis 715766.This value is
CONFIG_ENV_OFFSET(0xC0000) - the offset for U-Boot proper (69k) = 786432 − 69×1024 = 715776.The calculation itself is correct.
The first issue: CI does not report a build failure. However, my local build reports:
u-boot.img exceeds file size limit:
limit:0xaebf6bytes
actual:0xaed70bytes
excess:0x17abytes
make: *** [Makefile:1501: u-boot.img] Error 1
make: *** Deleting file 'u-boot.img'
make: *** Waiting for unfinished jobs....
u-boot-dtb.img exceeds file size limit:
limit:0xaebf6bytes
actual:0xaed70bytes
excess:0x17abytes
make: *** [Makefile:1501: u-boot-dtb.img] Error 1
make: *** Deleting file 'u-boot-dtb.img'
Quoted 3 lines
The second issue is that even if I remove the CONFIG_HAS_BOARD_SIZE_LIMIT/CONFIG_BOARD_SIZE_LIMIT, it builds, but fails to boot like this:
Ah, so toolchain mismatch problems. Newer GCC optimizes better.
Quoted 12 lines
U-Boot SPL 2025.07-rc5-00012-g7027b445cc0b-dirty (Jul 04 2025 - 13:22:16 -0300) Trying to boot from MMC1
This boot failure is related to the initcall series.
To avoid the mx6abresd boot regression and play safe for the upcoming 2025.07, I'm more inclined to go with the previous patch version that increases
CONFIG_BOARD_SIZE_LIMIT.Jerome said he is working on a better fix, which reduces the size by 1702 bytes for sabresd.
Quoted 8 lines
Having
CONFIG_BOARD_SIZE_LIMITwith too low a headroom may cause a problem where, on some build systems, such as U-Boot CI, the build succeeds, while others, like my local build, fail.Let's provide more
CONFIG_BOARD_SIZE_LIMITheadroom to avoid this situation from happening again.If you agree, feel free to pick v1.
I think Jerome has the wrong idea here. The previous problem was on armv5 CPUs, armv7 CPUs are thumb2 and aren't tripping this problem. I suspect that if you used gcc-14.2.0 from kernel.org to build, current top of tree mainline would work. I think we should still take this patch as it's both correct and saves much more space so that we aren't quite so close and so dependent on gcc optimizations.
Signature · 1 line
Tom
Quoted 6 lines · Tom Rini
I think Jerome has the wrong idea here. The previous problem was on armv5 CPUs, armv7 CPUs are thumb2 and aren't tripping this problem. I suspect that if you used gcc-14.2.0 from kernel.org to build, current top of tree mainline would work. I think we should still take this patch as it's both correct and saves much more space so that we aren't quite so close and so dependent on gcc optimizations.
Okay, I agree.
Please apply this v2 to master to restore the mx6sabresd boot.
Thanks
Quoted 9 lines · Fabio Estevam
The mx6sabresd U-Boot proper binary size has grown beyond the
CONFIG_BOARD_SIZE_LIMIT.Reduce its size by removing the
CONFIG_MULTI_DTB_FIT,BOOTM_PLAN9andBOOTM_RTEMSoptions.According to doc/README.multi-dtb-fit:
[...]
Applied to u-boot/master, thanks!
[1/1] mx6sabresd: Reduce U-Boot proper size to fix boot regression
commit: d1d53c252a4a746db5ebcdf0d6de3aa0feec504e
Signature · 1 line
Tom