Skip to content

Commit 2af6642

Browse files
c1728p9kjbracey
authored andcommitted
Add a platform config to disable the MPU
Add the platform config DISABLE_MPU to allow the MPU to be disabled from an application.
1 parent c180676 commit 2af6642

File tree

6 files changed

+9
-5
lines changed

6 files changed

+9
-5
lines changed

hal/mpu/mbed_mpu_v7m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_6M__ == 1U)) && \
2222
defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) && \
23-
!defined(MBED_MPU_CUSTOM)
23+
!defined(MBED_MPU_CUSTOM) && !MBED_CONF_PLATFORM_DISABLE_MPU
2424

2525
#if !DEVICE_MPU
2626
#error "Device has v7m MPU but it is not enabled. Add 'MPU' to device_has in targets.json"

hal/mpu/mbed_mpu_v8m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#if ((__ARM_ARCH_8M_BASE__ == 1U) || (__ARM_ARCH_8M_MAIN__ == 1U)) && \
2222
defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) && \
23-
!defined(MBED_MPU_CUSTOM)
23+
!defined(MBED_MPU_CUSTOM) && !MBED_CONF_PLATFORM_DISABLE_MPU
2424

2525
#if !DEVICE_MPU
2626
#error "Device has v8m MPU but it is not enabled. Add 'MPU' to device_has in targets.json"

hal/mpu_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
extern "C" {
2727
#endif
2828

29-
#if DEVICE_MPU
29+
#if DEVICE_MPU && !MBED_CONF_PLATFORM_DISABLE_MPU
3030

3131
/**
3232
* \defgroup hal_mpu MPU hal

platform/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128
"fatal-error-auto-reboot-enabled": {
129129
"help": "Setting this to true enables auto-reboot on a fatal error.",
130130
"value": false
131+
},
132+
"disable-mpu": {
133+
"help": "Disable the MPU to save rom.",
134+
"value": false
131135
}
132136
},
133137
"target_overrides": {

platform/mbed_mpu_mgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "hal/mpu_api.h"
2222
#include <limits.h>
2323

24-
#if DEVICE_MPU
24+
#if DEVICE_MPU && !MBED_CONF_PLATFORM_DISABLE_MPU
2525

2626
static uint16_t mem_xn_lock;
2727
static uint16_t mem_wn_lock;

platform/mbed_mpu_mgmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
extern "C" {
3333
#endif
3434

35-
#if DEVICE_MPU
35+
#if DEVICE_MPU && !MBED_CONF_PLATFORM_DISABLE_MPU
3636

3737
/** Lock ram execute never mode off
3838
*

0 commit comments

Comments
 (0)