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

How to specify ".non_init" section address and size to avoid clearing by SoftDevice or Bootloader

Hi there!

I am placing variables in the ".non_init" section so that their values are retained across software resets. This works great if I only use an App + Soft Device but I want to avoid the case where a Bootloader may potentially clear or overwrite the ".non_init" section, because it is not aware that it should keep that area of RAM intact.

1. How should I modify the flash_placement.xml file to specify the address and maximum allocated size of this section?

2. Where is a safe address, taking into account the heap that grows upwards and the stack that grows downwards?

3. What RAM areas are used by the Soft Device and should be avoided?

Thanks in advance,

Pieter

https://piconomix.com

Parents
  • Hi Vidar,

    Thank you! This is a great solution and I agree that it is the best place to put the .non_init section (above the stack).

    Your suggested changes to the XML file works perfectly but I'm not sure why it works.

    For the .stack section, the attribute place_from_segment_end="Yes". That implies that it should be placed at the end of RAM1 but instead the .non_init section is placed at the end of RAM1 and the.stack section is correctly placed below it. How does that work?

    Thanks in advance,

    Pieter

Reply
  • Hi Vidar,

    Thank you! This is a great solution and I agree that it is the best place to put the .non_init section (above the stack).

    Your suggested changes to the XML file works perfectly but I'm not sure why it works.

    For the .stack section, the attribute place_from_segment_end="Yes". That implies that it should be placed at the end of RAM1 but instead the .non_init section is placed at the end of RAM1 and the.stack section is correctly placed below it. How does that work?

    Thanks in advance,

    Pieter

Children
  • Hi Pieter,

    That implies that it should be placed at the end of RAM1 but instead the .non_init section is placed at the end of RAM1 and the

    Yes, I agree, it does imply that. I'm not familiar with the internals of how the linker scrip generator works, that's maybe a question Segger has to answer. I only found out it worked because I tried out different things with the flash placement file.

    Another option I found was to add ".place_from_segment_end" to the ".non_init" section, but that caused the cstack to be placed just above the application data (should be fine, but pretty much guarantees problems if you have a stack overrun). 

    Vidar

Related