Skip to content

Commit 5a80229

Browse files
Vincenzo Frascinorsalveti
authored andcommitted
[LTD fromlist] arm: soc: nxp k6x: Add Allow write on Flash
This patch adds the allow flash write CONFIG option to the NXP MPU configuration in privileged mode. Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org> Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org> LTD: some conflict resolution on top of what was posted to the list.
1 parent e97c7b6 commit 5a80229

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

arch/arm/core/cortex_m/mpu/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ config NXP_MPU
3838
default n
3939
help
4040
MCU has NXP MPU
41+
42+
config MPU_ALLOW_FLASH_WRITE
43+
bool "Add MPU access to write to flash"
44+
depends on NXP_MPU
45+
default n
46+
help
47+
Enable this to allow MPU RWX access to flash memory

include/arch/arm/cortex_m/mpu/nxp_mpu.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,29 @@
6262
#define ENDADDR_ROUND(x) (x - 0x1F)
6363

6464
/* Some helper defines for common regions */
65+
#if defined(CONFIG_MPU_ALLOW_FLASH_WRITE)
66+
/*
67+
* This config option enables the possibility to write in flash and to execute
68+
* from RAM since it is required to initialize the flash driver.
69+
*/
70+
#define REGION_RAM_ATTR (MPU_REGION_READ | \
71+
MPU_REGION_WRITE | \
72+
MPU_REGION_EXEC | \
73+
MPU_REGION_SU)
74+
75+
#define REGION_FLASH_ATTR (MPU_REGION_READ | \
76+
MPU_REGION_WRITE | \
77+
MPU_REGION_EXEC | \
78+
MPU_REGION_SU)
79+
#else
6580
#define REGION_RAM_ATTR (MPU_REGION_READ | \
6681
MPU_REGION_WRITE | \
6782
MPU_REGION_SU)
6883

6984
#define REGION_FLASH_ATTR (MPU_REGION_READ | \
7085
MPU_REGION_EXEC | \
7186
MPU_REGION_SU)
87+
#endif
7288

7389
#define REGION_IO_ATTR (MPU_REGION_READ | \
7490
MPU_REGION_WRITE | \

0 commit comments

Comments
 (0)