helium / helium/cortex-mpu

Problems getting it working

Open
#3 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
7
Forks
5
PR merge metrics
No merged PRs in 30d

Description

I have some problems getting it working, but maybe I am just using it wrong.

I have a STM32F411 Nucleo board, so MPU should be supported to my understanding.

I set it up like this:
~~~rust
#[exception]
fn MemoryManagement() -> ! {
rprintln!("Memory management error");
loop {
cortex_m::asm::nop();
}
}

#[entry]
fn main() -> ! {
let mut regions = ArrayVec::new();
let base = cortex_m_rt::heap_start() as usize;
regions.push(Region {
base_addr: base,
size: Size::S32B,
subregions: Subregions::ALL,
executable: false,
permissions: AccessPermission::NoAccess,
attributes: MemoryAttributes::Normal {
shareable: false,
cache_policy: CachePolicy::NonCacheable,
},
});

rprintln!("Configure MPU - base: 0x{:08x}", base);
let mut mpu = unsafe { Mpu::new(core.MPU) };
mpu.configure_unprivileged(®ions);

rprintln!("Try access");
unsafe {
ptr::write_volatile(base as *mut i32, 0);
}

rprintln!("Whoopsie");

loop {
cortex_m::asm::nop();
}
}
~~~

My expectation would be, that the point of "Whoopsie" is never reached. And it calls into the `fn MemoryManagement` instead.

However, the code just runs past that point.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.