Skip to content

Commit 1b36c6c

Browse files
mmahadevan108ioannisg
authored andcommitted
arch: arm: Create a MPU entry for relocated code
Code relocated using CONFIG_CODE_DATA_RELOCATION_SRAM should be allowed to execute from SRAM Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 3035b3a commit 1b36c6c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/arm/core/aarch32/cortex_m/mpu/arm_core_mpu.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ extern K_THREAD_STACK_DEFINE(z_main_stack, CONFIG_MAIN_STACK_SIZE);
5555
uint32_t z_arm_mpu_stack_guard_and_fpu_adjust(struct k_thread *thread);
5656
#endif
5757

58+
#if defined(CONFIG_CODE_DATA_RELOCATION_SRAM)
59+
extern char __sram_text_start[];
60+
extern char __sram_text_size[];
61+
#endif
62+
5863
static const struct z_arm_mpu_partition static_regions[] = {
5964
#if defined(CONFIG_COVERAGE_GCOV) && defined(CONFIG_USERSPACE)
6065
{
@@ -82,6 +87,14 @@ static const struct z_arm_mpu_partition static_regions[] = {
8287
.attr = K_MEM_PARTITION_P_RX_U_RX,
8388
},
8489
#endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */
90+
#if defined(CONFIG_CODE_DATA_RELOCATION_SRAM)
91+
{
92+
/* RAM area for relocated text */
93+
.start = (uint32_t)&__sram_text_start,
94+
.size = (uint32_t)&__sram_text_size,
95+
.attr = K_MEM_PARTITION_P_RX_U_RX,
96+
},
97+
#endif /* CONFIG_CODE_DATA_RELOCATION_SRAM */
8598
#if !defined(CONFIG_MULTITHREADING) && defined(CONFIG_MPU_STACK_GUARD)
8699
/* Main stack MPU guard to detect overflow.
87100
* Note:

0 commit comments

Comments
 (0)