Skip to content

Commit 7546186

Browse files
author
Cruz Monrreal
authored
Merge pull request #9040 from c1728p9/disable_mpu_config
Add a platform config to disable the MPU
2 parents 08d1127 + 770baa2 commit 7546186

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

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+
"use-mpu": {
133+
"help": "Use the MPU if available to fault execution from RAM and writes to ROM. Can be disabled to reduce image size.",
134+
"value": true
131135
}
132136
},
133137
"target_overrides": {

platform/mbed_mpu_mgmt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616

1717
#include "platform/mbed_mpu_mgmt.h"
1818
#include "platform/mbed_critical.h"
19-
#include "platform/mbed_error.h"
2019
#include "platform/mbed_assert.h"
2120
#include "hal/mpu_api.h"
2221
#include <limits.h>
2322

24-
#if DEVICE_MPU
23+
#if DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU
2524

2625
static uint16_t mem_xn_lock;
2726
static uint16_t mem_wn_lock;

platform/mbed_mpu_mgmt.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@
2323
#ifndef MBED_MPU_MGMT_H
2424
#define MBED_MPU_MGMT_H
2525

26-
#include "hal/sleep_api.h"
2726
#include "mbed_toolchain.h"
28-
#include "hal/ticker_api.h"
27+
#include "hal/mpu_api.h"
2928
#include <stdbool.h>
3029

3130
#ifdef __cplusplus
3231
extern "C" {
3332
#endif
3433

35-
#if DEVICE_MPU
34+
#if (DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU) || defined(DOXYGEN_ONLY)
35+
36+
#define mbed_mpu_manager_init() mbed_mpu_init()
3637

3738
/** Lock ram execute never mode off
3839
*
@@ -84,6 +85,8 @@ void mbed_mpu_manager_unlock_rom_write(void);
8485

8586
#else
8687

88+
#define mbed_mpu_manager_init() (void)0
89+
8790
#define mbed_mpu_manager_lock_ram_execution() (void)0
8891

8992
#define mbed_mpu_manager_unlock_ram_execution() (void)0

rtos/TARGET_CORTEX/mbed_boot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#include "mbed_toolchain.h"
7878
#include "mbed_boot.h"
7979
#include "mbed_error.h"
80-
#include "mpu_api.h"
80+
#include "mbed_mpu_mgmt.h"
8181

8282
int main(void);
8383
static void mbed_cpy_nvic(void);
@@ -88,7 +88,7 @@ uint32_t mbed_stack_isr_size = 0;
8888

8989
void mbed_init(void)
9090
{
91-
mbed_mpu_init();
91+
mbed_mpu_manager_init();
9292
mbed_cpy_nvic();
9393
mbed_sdk_init();
9494
mbed_rtos_init();

0 commit comments

Comments
 (0)