Skip to content

Commit 162054b

Browse files
iabdalkaderdpgeorge
authored andcommitted
stm32/mpu: Add MPU config for shared, uncached memory region.
Signed-off-by: iabdalkader <[email protected]>
1 parent b726022 commit 162054b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ports/stm32/mpu.h

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define MPU_REGION_QSPI3 (MPU_REGION_NUMBER3)
3737
#define MPU_REGION_SDRAM1 (MPU_REGION_NUMBER4)
3838
#define MPU_REGION_SDRAM2 (MPU_REGION_NUMBER5)
39+
#define MPU_REGION_OPENAMP (MPU_REGION_NUMBER15)
3940

4041
// Only relevant on CPUs with D-Cache, must be higher priority than SDRAM
4142
#define MPU_REGION_DMA_UNCACHED_1 (MPU_REGION_NUMBER6)
@@ -94,6 +95,18 @@
9495
| MPU_REGION_ENABLE << MPU_RASR_ENABLE_Pos \
9596
)
9697

98+
#define MPU_CONFIG_SHARED_UNCACHED(size) ( \
99+
MPU_INSTRUCTION_ACCESS_DISABLE << MPU_RASR_XN_Pos \
100+
| MPU_REGION_FULL_ACCESS << MPU_RASR_AP_Pos \
101+
| MPU_TEX_LEVEL1 << MPU_RASR_TEX_Pos \
102+
| MPU_ACCESS_SHAREABLE << MPU_RASR_S_Pos \
103+
| MPU_ACCESS_NOT_CACHEABLE << MPU_RASR_C_Pos \
104+
| MPU_ACCESS_NOT_BUFFERABLE << MPU_RASR_B_Pos \
105+
| 0x00 << MPU_RASR_SRD_Pos \
106+
| (size) << MPU_RASR_SIZE_Pos \
107+
| MPU_REGION_ENABLE << MPU_RASR_ENABLE_Pos \
108+
)
109+
97110
static inline void mpu_init(void) {
98111
MPU->CTRL = MPU_PRIVILEGED_DEFAULT | MPU_CTRL_ENABLE_Msk;
99112
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;

0 commit comments

Comments
 (0)