diff --git a/hal/mpu/mbed_mpu_v8m.c b/hal/mpu/mbed_mpu_v8m.c index a0bab96532..7304c149b9 100644 --- a/hal/mpu/mbed_mpu_v8m.c +++ b/hal/mpu/mbed_mpu_v8m.c @@ -78,7 +78,8 @@ void mbed_mpu_init() (3 << MPU_RBAR_AP_Pos) | // RO allowed by all privilege levels (0 << MPU_RBAR_XN_Pos); // Execute Never disabled MPU->RLAR = (0x1FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x1FFFFFFF - (region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number + (region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number + (1 << MPU_RLAR_EN_Pos); // Region enabled region = 1; MPU->RNR = region; @@ -90,7 +91,8 @@ void mbed_mpu_init() (1 << MPU_RBAR_AP_Pos) | // RW allowed by all privilege levels (1 << MPU_RBAR_XN_Pos); // Execute Never enabled MPU->RLAR = (0x3FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x3FFFFFFF - (region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number + (region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number + (1 << MPU_RLAR_EN_Pos); // Region enabled region = 2; MPU->RNR = region; @@ -102,7 +104,8 @@ void mbed_mpu_init() (1 << MPU_RBAR_AP_Pos) | // RW allowed by all privilege levels (1 << MPU_RBAR_XN_Pos); // Execute Never enabled MPU->RLAR = (0x7FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x7FFFFFFF - (region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number + (region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number + (1 << MPU_RLAR_EN_Pos); // Region enabled region = 3; MPU->RNR = region; @@ -114,7 +117,8 @@ void mbed_mpu_init() (1 << MPU_RBAR_AP_Pos) | // RW allowed by all privilege levels (1 << MPU_RBAR_XN_Pos); // Execute Never enabled MPU->RLAR = (0x9FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x9FFFFFFF - (region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number + (region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number + (1 << MPU_RLAR_EN_Pos); // Region enabled // Enable the MPU MPU->CTRL = diff --git a/hal/mpu_api.h b/hal/mpu_api.h index 5c02c740ff..5ce034779e 100644 --- a/hal/mpu_api.h +++ b/hal/mpu_api.h @@ -64,8 +64,8 @@ extern "C" { * Initialize the MPU * * Initialize or re-initialize the memory protection unit. - * It is implementation defined what region are protected - * by the MPU after initialization. + * After initialization or re-initialization, ROM and RAM protection + * are both enabled. */ void mbed_mpu_init(void); @@ -75,7 +75,9 @@ void mbed_mpu_init(void); * This function is used to mark all of ROM as read and execute only. * When enabled writes to ROM cause a fault. * - * @param enable true to disable execution in ram, false otherwise + * By default writes to ROM are disabled. + * + * @param enable true to disable writes to ROM, false otherwise */ void mbed_mpu_enable_rom_wn(bool enable); @@ -85,7 +87,9 @@ void mbed_mpu_enable_rom_wn(bool enable); * This function is used to mark all of RAM as execute never. * When enabled code is only allowed to execute from flash. * - * @param enable true to disable execution in ram, false otherwise + * By default execution from RAM is disabled. + * + * @param enable true to disable execution from RAM, false otherwise */ void mbed_mpu_enable_ram_xn(bool enable); diff --git a/rtos/TARGET_CORTEX/mbed_boot.c b/rtos/TARGET_CORTEX/mbed_boot.c index ccca64aa72..2e73d92a8e 100644 --- a/rtos/TARGET_CORTEX/mbed_boot.c +++ b/rtos/TARGET_CORTEX/mbed_boot.c @@ -88,8 +88,6 @@ uint32_t mbed_stack_isr_size = 0; void mbed_init(void) { mbed_mpu_init(); - mbed_mpu_enable_ram_xn(true); - mbed_mpu_enable_rom_wn(true); mbed_cpy_nvic(); mbed_sdk_init(); mbed_rtos_init();