Memory isolation

S115 SoftDevice

When the SoftDevice is enabled, the RAM is split into several regions, which are defined at Application compile time. The SoftDevice RAM Region is located between the addresses 0x20000080 and APP_RAM_BASE - 1 and is used by the SoftDevice. The Application RAM Region is located between the addresses APP_RAM_BASE and the top of RAM and is available to the application.

Note: RAM 0x20000000-0x2000007F is reserved for CRACEN.

The following figure presents an overview of the regions.

Figure 1. Memory region designation
Memory region designation

The SoftDevice uses a fixed amount of NVM program memory. By contrast, the size of the SoftDevice RAM Region depends on whether the SoftDevice is enabled or not, and on the selected Bluetooth® Low Energy protocol stack configuration. See Role configuration for more details.

The amount of NVM and RAM available to the application is determined by region size (kilobytes or bytes) and the SD_CODE_BASE and APP_RAM_BASE addresses which are the base addresses of the SoftDevice code and application RAM, respectively. The application code must be located between start of NVM (0x0000 0000) and SD_CODE_BASE. The application variables must be allocated in an area inside the Application RAM Region, located between APP_RAM_BASE and <size of RAM>. This area shall not overlap with the allocated RAM space for the call stack and heap, which is also located inside the Application RAM Region.

The program code address range of an example application:

0x0000 0000 ≤ Program < SD_CODE_BASE

RAM address range of example application assuming call stack and heap location as shown in Memory resource map:

APP_RAM_BASE ≤ RAM < (0x2000 0000 + <size of RAM>) - (<Call Stack> + <Heap>)

When the SoftDevice is disabled, all RAM is available to the application. See Memory resource map and usage for more details. When the SoftDevice is enabled, RAM up to APP_RAM_BASE is used by the SoftDevice.

The typical location of the call stack for an application using the SoftDevice is in the upper part of the Application RAM Region, so the application can place its variables from the end of the SoftDevice RAM Region (APP_RAM_BASE) to the beginning of the call stack space.

Note:
  • The location of the call stack is communicated to the SoftDevice through the contents of the Main Stack Pointer (MSP) register.
  • Do not change the value of MSP dynamically (that is, never set the MSP register directly).
  • The RAM located in the SoftDevice RAM Region is overwritten once the SoftDevice is enabled.
  • The SoftDevice RAM Region is not cleared or restored to default values after disabling the SoftDevice, so the application must treat the contents of the region as uninitialized memory.