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

RAM retention settings with SoftDevice enabled

Hello,

 

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image. I am using ‘ble_app_blinky’.

I have few variables in application. These will be keep on changing based on different conditions in application. Other than power reset, those variables to be retained both in System ON and System OFF mode.

 

1) I searched entire ble_app_blinky project but I could not find sd_power_ram_power_set(). Still RAM content retained, when device wakes from “System ON” mode.

a) Whether SoftDevice will enable these settings, so that variables are retained even in System ON mode.

b) (Or) Since by default after reset, both bits A & B are set to 1 indicating RAM section S0 & S1 are enabled by default in System OF mode.

2) Device went to System OFF mode. But content in variables are lost. As per below links

a) I want to retain entire RAM rather than ".retained_section" for different variables.

b) If entire RAM is not retained during System OFF, then what is the purpose of S0RETENTION and S1RETENTION in RAM[0].POWER register.

c) Whether blow code is good enough so that entire RAM will retained even in System OFF mode.  But still I am not able to see the retained value.

https://devzone.nordicsemi.com/f/nordic-q-a/47620/ram-retention-of-softdevice-ram-region

https://devzone.nordicsemi.com/f/nordic-q-a/36099/ram-retention-problem

    uint8_t i;
    for(i = 0; i < 8; i++) // Retain RAM 0 - RAM 7
    {
        sd_power_ram_power_set(i, (POWER_RAM_POWER_S0POWER_On << POWER_RAM_POWER_S0POWER_Pos) |
                                  (POWER_RAM_POWER_S1POWER_On << POWER_RAM_POWER_S1POWER_Pos) |
                                  (POWER_RAM_POWER_S0RETENTION_On << POWER_RAM_POWER_S0RETENTION_Pos) |
                                  (POWER_RAM_POWER_S1RETENTION_On << POWER_RAM_POWER_S1RETENTION_Pos));
    }
    
    u8SystemOFFTestCounter++;
    // Start execution.
    NRF_LOG_INFO("SystemOFF Test %d", u8SystemOFFTestCounter);

3) Even I thought to skip GPIO initialization. Since variables are not retained in RAM, I am getting code crash.

    /* Reset reason */
    uint32_t rr = log_resetreason();
    
    // During System OFF mode, no need to re-initialize GPIO pins (This will avoid Glitch on pins)
    if(rr == NRF_POWER_RESETREAS_OFF_MASK)
    {
        leds_init();
        buttons_init();
    }

Also I have gone through "ram_retention" which is without softDevice and "ble_app_pwr_profiling" example where sd_power_ram_power_set() is no where called. I am bit confused.

I have gone through lot of mails on forum. But there is not straight froward answer.

Do we need to change any Segger settings to avoid RAM initialization while wake-up from System OFF. Please take this issue on high priority.

Thanks & Regards

Vishnu Beema

Parents
  • Hi Vishnu

    1. RAM retention in system ON mode is enabled by default, that is correct. Most applications use system ON idle mode continuously, and having at least partial RAM retention is critical. 

    2. a. Most examples come with a .non_init section that can be used to declare retained variables, without having to make any changes to the flash_placement.xml file. 

    To do this just declare the variables like this:

    static uint32_t my_variable __attribute__((section(".non_init")));

    b. Technically the RAM is still retained, but it gets zero initialized during the reset sequence. I agree it doesn't make sense to enable RAM retention if you don't put the memory in the .non_init section. 

    c. That code should suffice, yes. Can you try using the .non_init section like I suggested earlier and see if it works?

    3. What part of the code causes the crash? 

    Do you get an assert from the SoftDevice, or an error code in return from one of the SDK modules?

    Best regards
    Torbjørn

Reply
  • Hi Vishnu

    1. RAM retention in system ON mode is enabled by default, that is correct. Most applications use system ON idle mode continuously, and having at least partial RAM retention is critical. 

    2. a. Most examples come with a .non_init section that can be used to declare retained variables, without having to make any changes to the flash_placement.xml file. 

    To do this just declare the variables like this:

    static uint32_t my_variable __attribute__((section(".non_init")));

    b. Technically the RAM is still retained, but it gets zero initialized during the reset sequence. I agree it doesn't make sense to enable RAM retention if you don't put the memory in the .non_init section. 

    c. That code should suffice, yes. Can you try using the .non_init section like I suggested earlier and see if it works?

    3. What part of the code causes the crash? 

    Do you get an assert from the SoftDevice, or an error code in return from one of the SDK modules?

    Best regards
    Torbjørn

Children
No Data
Related