Skip to content

Commit 17b4789

Browse files
committed
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 <[email protected]>
1 parent 5249619 commit 17b4789

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# STM32L552ZE-Q Nucleo board configuration
2+
3+
# Copyright (c) 2024 STMicroelectronics
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
if BOARD_NUCLEO_L552ZE_Q
7+
8+
if BUILD_WITH_TFM
9+
10+
# Not defining LIBC malloc arena has the effect of declaring all available RAM
11+
# as available for malloc.
12+
# This currently conflicts with TF-M MPU setting, resulting in a hard fault.
13+
# Define a specific size to avoid this situation.
14+
15+
config COMMON_LIBC_MALLOC_ARENA_SIZE
16+
default 2048
17+
18+
endif # BUILD_WITH_TFM
19+
20+
endif # BOARD_NUCLEO_L552ZE_Q

boards/st/stm32l562e_dk/Kconfig.defconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,16 @@ endchoice
3030

3131
endif # DISPLAY
3232

33+
if BUILD_WITH_TFM
34+
35+
# Not defining LIBC malloc arena has the effect of declaring all available RAM
36+
# as available for malloc.
37+
# This currently conflicts with TF-M MPU setting, resulting in a hard fault.
38+
# Define a specific size to avoid this situation.
39+
40+
config COMMON_LIBC_MALLOC_ARENA_SIZE
41+
default 2048
42+
43+
endif # BUILD_WITH_TFM
44+
3345
endif # BOARD_STM32L562E_DK

0 commit comments

Comments
 (0)