Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RAM retention between system resets (#pragma NOINIT replacement)

Hi,

My application is based of ble_freertos_hrs example (SDK 14.2, nRF52832) and I need some variables to survive an assertion.

It appears that Keil has deprecated #pragma NO_INIT that did just that.

I've noticed a post dealing with same issues here, but unfortunately, I find it very hard to follow as I'm not very familiar with Linker configuration files etc.

Is there a simple step-by-step guideline as how to make it work?

Thanks

Parents
  • Hi,

    We used to allocate a no init section in our legacy bootloader for sharing data between application and bootloader (pre-SDK12). You can copy this approach to your example, it doesn't require you to edit any linker/scatter files. 

    Steps:

    1. Define the variable you want to keep retained with  __attribute__((section("NoInit"), zero_init)); .e.g, static uint32_t dummy __attribute__((section("NoInit"), zero_init)); 

    2. Open option for target options allocate a new memory segment and tick the "NoInit" checkbox.

    3. Right click on the source file you defined the variable in and select "options for File..". Then select the new ram section you created from the dropdown menu for Zero initialized data.

    4. Dummy variable should now be linked to the IRAM2 section.

Reply
  • Hi,

    We used to allocate a no init section in our legacy bootloader for sharing data between application and bootloader (pre-SDK12). You can copy this approach to your example, it doesn't require you to edit any linker/scatter files. 

    Steps:

    1. Define the variable you want to keep retained with  __attribute__((section("NoInit"), zero_init)); .e.g, static uint32_t dummy __attribute__((section("NoInit"), zero_init)); 

    2. Open option for target options allocate a new memory segment and tick the "NoInit" checkbox.

    3. Right click on the source file you defined the variable in and select "options for File..". Then select the new ram section you created from the dropdown menu for Zero initialized data.

    4. Dummy variable should now be linked to the IRAM2 section.

Children
Related