Skip to content

Commit 3226cf5

Browse files
Alain Volmatcfriedt
authored andcommitted
soc: stm32: stm32h7rsx: add MPU region #0 disabling all accesses
Add a first region in the MPU to disable all access to the whole memory range. With that ensure that the MPU will block all access to regions that aren't defined in further regions. Ensure as well that the peripheral area is accessible. This handles the errata 2.1.1 PLD might perform linefill to address that would generate a MemManage Fault of the STM32H7Rxx / STM32H7Sxx device errate ES0596 - Rev 6. Signed-off-by: Alain Volmat <[email protected]>
1 parent 866dff0 commit 3226cf5

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

soc/st/stm32/stm32h7rsx/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ zephyr_sources(
55
soc.c
66
)
77

8+
zephyr_sources(mpu_regions.c)
9+
810
zephyr_include_directories(.)
911

1012
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")

soc/st/stm32/stm32h7rsx/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config SOC_SERIES_STM32H7RSX
1111
select HAS_STM32CUBE
1212
select CPU_HAS_ARM_MPU
1313
select HAS_SWO
14+
select CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS
1415
select CPU_HAS_FPU_DOUBLE_PRECISION
1516
select CPU_HAS_ICACHE
1617
select CPU_HAS_DCACHE
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2017 Linaro Limited.
3+
* Copyright (c) 2025 STMicroelectronics
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <zephyr/sys/slist.h>
9+
#include <zephyr/arch/arm/mpu/arm_mpu.h>
10+
11+
#include <zephyr/arch/arm/cortex_m/arm_mpu_mem_cfg.h>
12+
13+
static const struct arm_mpu_region mpu_regions[] = {
14+
/* Use first region to prevent speculative access in entire memory space */
15+
/* Region 0 */
16+
MPU_REGION_ENTRY("UNMAPPED", 0, {REGION_4G | MPU_RASR_XN_Msk | P_NA_U_NA_Msk}),
17+
18+
/* Region 1 */
19+
MPU_REGION_ENTRY("PERIPH", 0x40000000, REGION_IO_ATTR(REGION_512M)),
20+
21+
#ifdef CONFIG_XIP
22+
/* Region 2 */
23+
MPU_REGION_ENTRY("FLASH_0", CONFIG_FLASH_BASE_ADDRESS,
24+
REGION_FLASH_ATTR(REGION_FLASH_SIZE)),
25+
#endif
26+
27+
/* Region 3 */
28+
MPU_REGION_ENTRY("SRAM_0", CONFIG_SRAM_BASE_ADDRESS, REGION_RAM_ATTR(REGION_SRAM_SIZE)),
29+
};
30+
31+
const struct arm_mpu_config mpu_config = {
32+
.num_regions = ARRAY_SIZE(mpu_regions),
33+
.mpu_regions = mpu_regions,
34+
};

0 commit comments

Comments
 (0)