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

Can I use MPU to mark all of SRAM as XN, when using SoftDevice v5.0.0?

Similar question to https://devzone.nordicsemi.com/f/nordic-q-a/38571/can-i-use-mpu-to-mark-memory-as-xn-when-using-softdevice

but this is specifically about SoftDevice v5.0.0. Does this version of SoftDevice run any code from RAM?

If not, is it therefore safe to mark all of SRAM [0x20000000 - 0x20010000] as XN using the MPU?

nRF SDK v 14.1, SoftDevice v5.0.0

Thanks in advance!

Parents
  • Hi,

    Does this version of SoftDevice run any code from RAM?

    No, it does not.

    If not, is it therefore safe to mark all of SRAM [0x20000000 - 0x20010000] as XN using the MPU?

    Yes, that should be safe. But it might not be necessary. The SoftDevice protects the SoftDevice RAM Region so that it cannot be written to by the application at runtime using the MWU. Violation of sandboxing rules, for example, an attempt to write to the protected SoftDevice memory, will result in the triggering of a fault (unrecoverable error handled by the application).

Reply
  • Hi,

    Does this version of SoftDevice run any code from RAM?

    No, it does not.

    If not, is it therefore safe to mark all of SRAM [0x20000000 - 0x20010000] as XN using the MPU?

    Yes, that should be safe. But it might not be necessary. The SoftDevice protects the SoftDevice RAM Region so that it cannot be written to by the application at runtime using the MWU. Violation of sandboxing rules, for example, an attempt to write to the protected SoftDevice memory, will result in the triggering of a fault (unrecoverable error handled by the application).

Children
  • That's great, thanks for the quick response.

    The reason that I'm keen to protect all of SRAM is that the MPU has restrictions on the regions that it can protect: namely a region must begin at an address that's naturally aligned with the region size. For that reason it seems much simpler to set all of SRAM as a single region with XN set, than to try and determine, at runtime, where SoftDevice ends and then to figure out the necessary region size and alignment.

Related