arm - MPU does not protect memory access -


i want use cortex-m3 mpu protect memory unintended access. purpose configured mpu. did not exception @ all. other exceptions busfault, hardfault has been forced appropriate "bad code".

the current initialization is

mpu->ctrl &= ~mpu_ctrl_enable_msk;       // disable mpu  mpu->rnr  = 0 mpu->rbar = 0x20000000; mpu->rasr = 0x03000019; // 0x03ul << (mpu_rasr_attrs_pos+8) | (0x19ul << 0);  mpu->rnr  = 1; mpu->rbar = 0x8000000;  // read 0x8000001 mpu->rasr = 0x03000027; // 0x03ul << (mpu_rasr_attrs_pos+8) | (0x27ul << 0);   mpu->rnr  = 2; mpu->rbar = 0x40000000; // read 0x40000002 mpu->rasr = 0x13000039; // 0x13ul << (mpu_rasr_attrs_pos+8) | (0x39ul << 0);   scb->shcsr |= scb_shcsr_memfaultena_msk;  // enable memory fault exception  mpu->ctrl |= mpu_ctrl_privdefena_msk | mpu_ctrl_enable_msk;   // enable mpu 

until can access memory. add region protect region.

mpu->ctrl &= ~mpu_ctrl_enable_msk; // disable mpu  mpu->rnr = 3; mpu->rbar = 0x20002000;  // read 0x20002003 mpu->rasr = 0x00000009;  // 0x00ul << (mpu_rasr_attrs_pos+8) | (0x09ul << 0);  mpu->ctrl |= mpu_ctrl_privdefena_msk | mpu_ctrl_enable_msk; // re-enable mpu 

the region number 3 should hide other mpu regions. memory @ 0x20002000 should not accessible neither readable not writable. can still read , write memory @ address.

what can inhibit memory protection in nxp lpc1788 cpu?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -