Skip to content

Commit

Permalink
arm: aarch32: config static regions with MPU disabled
Browse files Browse the repository at this point in the history
There is the possibility that when reconfiguring the static regions,
some data that must be accessed is temporarily not accesible due to the
change on the MPU regions configuration. Workaround by disabling MPU
when doing the reconfiguration, same as with dynamic regions, until BR
can be enabled.

Signed-off-by: Duong Vu Nam <[email protected]>
  • Loading branch information
duongvunam authored and carlescufi committed Dec 12, 2022
1 parent 47cce05 commit 84b5d39
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions arch/arm/core/aarch32/mpu/arm_core_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(mpu);

extern void arm_core_mpu_enable(void);
extern void arm_core_mpu_disable(void);

/*
* Maximum number of dynamic memory partitions that may be supplied to the MPU
* driver for programming during run-time. Note that the actual number of the
Expand Down Expand Up @@ -131,10 +134,16 @@ void z_arm_configure_static_mpu_regions(void)
* of the firmware SRAM area is marked by __kernel_ram_end, taking
* into account the unused SRAM area, as well.
*/
#ifdef CONFIG_AARCH32_ARMV8_R
arm_core_mpu_disable();
#endif
arm_core_mpu_configure_static_mpu_regions(static_regions,
ARRAY_SIZE(static_regions),
(uint32_t)&_image_ram_start,
(uint32_t)&__kernel_ram_end);
#ifdef CONFIG_AARCH32_ARMV8_R
arm_core_mpu_enable();
#endif

#if defined(CONFIG_MPU_REQUIRES_NON_OVERLAPPING_REGIONS) && \
defined(CONFIG_MULTITHREADING)
Expand All @@ -155,8 +164,6 @@ void z_arm_configure_static_mpu_regions(void)
#endif /* CONFIG_MPU_REQUIRES_NON_OVERLAPPING_REGIONS */
}

extern void arm_core_mpu_enable(void);
extern void arm_core_mpu_disable(void);
/**
* @brief Use the HW-specific MPU driver to program
* the dynamic MPU regions.
Expand Down

0 comments on commit 84b5d39

Please sign in to comment.