This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832: Disable executable RAM?

We're using the nRF52832 and want to trap if various parts of RAM are ever executed. We'd like to restrict as much as possible. We run nRF SDK 14.0.0 and SD132v5.

Seeing that SoftDevice claims ownership of the MWU, what's the recommended way to trap when code runs in our application's RAM?

Thanks,

Charles

  • Similarly, I'd like to put a trap-on-write at what we want the top of our stack to be, so that we can catch stack overflowing into .data. These sound like the same mechanism from a CPU perspective, so I figured I'd ask here.

  • Hi,

    I am sorry for the late reply. I have not found the answer yet, but I hope to figure this out tomorrow. I will also take your second question into account.

    Regards,
    Terje

  • Hi,

    I am afraid that you have few options since the MWU cannot be used when the SoftDevice is enabled. While access to the MWU peripheral is not enforced per se, it is still used by the SoftDevice and so trying to use it from the application may lead to undefined behavior. I do not know if it is even possible. If you try to figure out what regions are not used by the SoftDevice (if any) and try to use them then I cannot give any guarantees as to how it will work or what will happen if you update to a different SoftDevice.

    Regarding stack overflow you can figure out what is the worst case stack usage of your application through testing, by reading the memory of the device and see where the stack has grown (i.e. non-0xFF region.) Or by code analysis.

    You can find maximum call stack usage for the SoftDevice in the SoftDevice release notes. (For s132 it has not been written in the release notes for the most recent releases, but it has been unchanged at 0x05f4 bytes since 5.0.0-3.alpha. I have asked for getting it back into the release notes for future releases, even if it does not change.)

    Regards,
    Terje

  • We've committed to s132 5.0.0 and SDK 14.0.0 for launch. Are there any version-specific guarantees you can make? Are all of the MWU watches in use? Can we use any of them?

    It's extremely unsafe to ship IoT devices that can execute arbitrary RAM (I'm assuming this is why SoftDevice uses it)

  • Hi,

    In addition to the MWU, the ARM Cortex-M CPU in the nRF52832 is actually equipped with a Memory Protection Unit (MPU) module. We even have an MPU driver in the SDK, although you will have to look at the ARM Cortex-M MPU documentation for figuring out how to use it.

    It is easy to get confused by terminology here, as for the nRF51 series in some situations we used the term MPU for the flash and peripheral protection used by the SoftDevice.

    Regards,
    Terje

Related