From 17b4789b3281f47c09639b734ed4e03c1b61e581 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Wed, 6 Nov 2024 09:33:22 +0100 Subject: [PATCH] boards: st: stm32l5: Fix TF-M by restricting Libc malloc aera By default, libc malloc allocated area is using all available RAM. For some yet unknown reason, this conflicts with TF-M resulting in a Hard Fault before jumping in the non secure application. For now, define a Libc malloc area defined to 2048 which is the default in some other typical applications (ARMv7 targets enabling USERSPACE). Fixes #77847 Signed-off-by: Erwan Gouriou --- boards/st/nucleo_l552ze_q/Kconfig.defconfig | 20 ++++++++++++++++++++ boards/st/stm32l562e_dk/Kconfig.defconfig | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 boards/st/nucleo_l552ze_q/Kconfig.defconfig diff --git a/boards/st/nucleo_l552ze_q/Kconfig.defconfig b/boards/st/nucleo_l552ze_q/Kconfig.defconfig new file mode 100644 index 0000000000000..901b4cf1ad694 --- /dev/null +++ b/boards/st/nucleo_l552ze_q/Kconfig.defconfig @@ -0,0 +1,20 @@ +# STM32L552ZE-Q Nucleo board configuration + +# Copyright (c) 2024 STMicroelectronics +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NUCLEO_L552ZE_Q + +if BUILD_WITH_TFM + +# Not defining LIBC malloc arena has the effect of declaring all available RAM +# as available for malloc. +# This currently conflicts with TF-M MPU setting, resulting in a hard fault. +# Define a specific size to avoid this situation. + +config COMMON_LIBC_MALLOC_ARENA_SIZE + default 2048 + +endif # BUILD_WITH_TFM + +endif # BOARD_NUCLEO_L552ZE_Q diff --git a/boards/st/stm32l562e_dk/Kconfig.defconfig b/boards/st/stm32l562e_dk/Kconfig.defconfig index 118968f4c082a..7547fd3eb9c34 100644 --- a/boards/st/stm32l562e_dk/Kconfig.defconfig +++ b/boards/st/stm32l562e_dk/Kconfig.defconfig @@ -30,4 +30,16 @@ endchoice endif # DISPLAY +if BUILD_WITH_TFM + +# Not defining LIBC malloc arena has the effect of declaring all available RAM +# as available for malloc. +# This currently conflicts with TF-M MPU setting, resulting in a hard fault. +# Define a specific size to avoid this situation. + +config COMMON_LIBC_MALLOC_ARENA_SIZE + default 2048 + +endif # BUILD_WITH_TFM + endif # BOARD_STM32L562E_DK