Skip to content

Add a platform config to disable the MPU #9040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions platform/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
"fatal-error-auto-reboot-enabled": {
"help": "Setting this to true enables auto-reboot on a fatal error.",
"value": false
},
"use-mpu": {
"help": "Use the MPU if available to fault execution from RAM and writes to ROM. Can be disabled to reduce image size.",
"value": true
}
},
"target_overrides": {
Expand Down
3 changes: 1 addition & 2 deletions platform/mbed_mpu_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

#include "platform/mbed_mpu_mgmt.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_error.h"
#include "platform/mbed_assert.h"
#include "hal/mpu_api.h"
#include <limits.h>

#if DEVICE_MPU
#if DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU

static uint16_t mem_xn_lock;
static uint16_t mem_wn_lock;
Expand Down
9 changes: 6 additions & 3 deletions platform/mbed_mpu_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
#ifndef MBED_MPU_MGMT_H
#define MBED_MPU_MGMT_H

#include "hal/sleep_api.h"
#include "mbed_toolchain.h"
#include "hal/ticker_api.h"
#include "hal/mpu_api.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

#if DEVICE_MPU
#if (DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU) || defined(DOXYGEN_ONLY)

#define mbed_mpu_manager_init() mbed_mpu_init()

/** Lock ram execute never mode off
*
Expand Down Expand Up @@ -84,6 +85,8 @@ void mbed_mpu_manager_unlock_rom_write(void);

#else

#define mbed_mpu_manager_init() (void)0

#define mbed_mpu_manager_lock_ram_execution() (void)0

#define mbed_mpu_manager_unlock_ram_execution() (void)0
Expand Down
4 changes: 2 additions & 2 deletions rtos/TARGET_CORTEX/mbed_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
#include "mbed_toolchain.h"
#include "mbed_boot.h"
#include "mbed_error.h"
#include "mpu_api.h"
#include "mbed_mpu_mgmt.h"

int main(void);
static void mbed_cpy_nvic(void);
Expand All @@ -88,7 +88,7 @@ uint32_t mbed_stack_isr_size = 0;

void mbed_init(void)
{
mbed_mpu_init();
mbed_mpu_manager_init();
mbed_cpy_nvic();
mbed_sdk_init();
mbed_rtos_init();
Expand Down