This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Usefulness of MPU in a non-OS system

Hi.

We are developing a product which has to achieve some safety requirements. The system is quite simple, non-OS, running in a Privileged mode only on a Cortex-M4. I would like to implement a Memory Protection Unit somehow. Could you please give any advice, in which way could be MPU implemented for that kind of system?

If I am correct, one possibility is to protect system from stack overflow. Any other thoughts?

Thank you

Parents
  • Even without an OS the MPU can be used to provide an OS-like set of protections,

    So yes, stack overflow is possible - you just need to position the end of the stack so it hits a fault region (not always true - many implementations will grow the stack downwards towards the heap, so stack overflow won't fault, it will just corrupt the heap). The other common protection it provides is making code sections read-only, stopping invalid pointer bugs corrupting the code randomly.

    The big advantage of using the MPU as much as possible is that you will capture faults at the point they happen, rather than randomly corrupting some memory, and then having the software fail in unpredictable ways some time later when that memory is used expecting the non-corrupted value in there (as either code or data). It will cut down on development and debug time if nothing else ...

    HTH,
    Pete

Reply
  • Even without an OS the MPU can be used to provide an OS-like set of protections,

    So yes, stack overflow is possible - you just need to position the end of the stack so it hits a fault region (not always true - many implementations will grow the stack downwards towards the heap, so stack overflow won't fault, it will just corrupt the heap). The other common protection it provides is making code sections read-only, stopping invalid pointer bugs corrupting the code randomly.

    The big advantage of using the MPU as much as possible is that you will capture faults at the point they happen, rather than randomly corrupting some memory, and then having the software fail in unpredictable ways some time later when that memory is used expecting the non-corrupted value in there (as either code or data). It will cut down on development and debug time if nothing else ...

    HTH,
    Pete

Children
No data