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

S132 5.1.0 excessive RAM usage

From the S132 5.1.0 specification, I expect that its RAM usage should be only 0x1228 bytes plus ATTR_TAB_SIZE. However, when I compile two of the example projects using IAR, I'm seeing an APP_RAM_BASE higher than expected, in one case by an extra 16KB. Both projects use the default ATTR_TAB_SIZE of 0x580 bytes, so I expect that the APP_RAM_BASE should be 0x200017a8. What I actually get is:

ble_app_uart_pca10040_s132: 0x20002a68

ble_app_hrs_freertos_pca10040_s132: 0x20005668 (22KB of RAM used by SoftDevice!)

Where is all that RAM going? The IAR linker script for hrs_freertos has that specific addresses configured, and I confirmed that app_ram_start_link and the app RAM start address returned by nrf_sdh_ble_default_cfg_set() match.

Is there something else that also uses RAM below APP_RAM_BASE, or is there some other configuration that causes S132 to use more RAM? The linker map confirms that nothing else is linked to RAM below APP_RAM_BASE, so all the application and FreeRTOS memory is above that.

I'm starting a new project for a client, which will use S132 and FreeRTOS, so I thought hrs_freertos would be the logical example to start from, but I can't use that project as the base if the APP_RAM_BASE is that high.

Update: I built the ble_app_hrs_freertos_pca10040_s132 app with SDK 12 for S132 3.1.0, and the APP_RAM_BASE for that is 0x20002128, which is quite reasonable. So why has the S132 RAM usage for the project gone berzerk sometime after SDK 12? (I haven't tried SDK 13 yet.)

Update 2: I tried building the same app with SDK 13.1, for comparison, but building it with IAR 8.20.1 fails with compile errors:

Error[Og014]: Warning in inline assembly: "DC or DS directive while in CODE area." C:\nordic\nRF5_SDK_13.1.0_7ca7556\external\freertos\portable\IAR\nrf52\port.c 115 
Error[Og014]: Warning in inline assembly: "DC or DS directive while in CODE area." C:\nordic\nRF5_SDK_13.1.0_7ca7556\external\freertos\portable\IAR\nrf52\port.c 143 
Error[Og014]: Warning in inline assembly: "DC or DS directive while in CODE area." C:\nordic\nRF5_SDK_13.1.0_7ca7556\external\freertos\portable\IAR\nrf52\port.c 199 
  • Hi Eric,

    I believe it's just a mistake. The RAM requirement from the softdevice is 0x200020E0 and IRAM1 size can be adjusted to 0xDF20

  • Hung Bui's comment is correct. For the ble_app_hrs_freertos_pca10040_s132 app with SDK 14.2 and S132 5.1.0, just changing the start of RAM variable in the linker script to a lower value works fine with IAR. (Possibly a different toolchain needs the IRAM1 size change he mentions, but IAR doesn't seem to use that.)

    With those specific versions, the lowest RAM start address that works for that project is 0x20001f50. I'm still not sure why that's about 2KB higher than what the S132 specification indicates, which would be 0x200017a8, but it leaves enough RAM for my application.

Related