Giter Site home page Giter Site logo

cortex-mpu's People

Contributors

jonas-schievink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cortex-mpu's Issues

Problems getting it working

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:

#[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(&regions);

    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.

Use of ArrayVec might be inefficient

ArrayVec tends to optimize relatively badly. I've used it to express the constraint "up to N memory regions", so we'd have to find a different way to express that.

Ideally the generated code shouldn't do more than just store any dynamic values and create a list of Regions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.