RAM and Flash start adresses

Hello,

I was reading this post on the forum: "Adjustment of RAM and Flash memory - Getting Started - nRF5 SDK guides - Nordic DevZone (nordicsemi.com)"

At point 4. "Change start addresses in Segger Embedded Studio" I wondered if you change the start adress of RAM to an adress that is further then the original adress. What happens to the RAM that is not defined?

Does the linker not put code there anymore? If that is true, is there any way you can put your own specific code there?

I want to achieve a data block where I can put specific arrays in and where the linker does not put anything else in.

  • Hi Chriis,

    If you are referring to the RAM_START configuration, then the RAM the application "moved away" from is going to be reserved for the SoftDevice.

    Regarding reserving a RAM section for variable, I am going to refer you to some answers by my colleagues on DevZone:

    - How to place data at a location by Einar:  RE: RAM Section allocated by Linker . 
    - Details about RAM usage and variable placement in RAM by Håkon: RE: Some questions about RAM non_init .
    - Another thread where a bootloader is also used: how to reserve memory segment using SES . 

    If you have any further questions please let me know.

    Hieu

  • Thanks for answering!

    I am quite new to this so I may find understanding a little harder than usual so please bear that in mind.

    My goal is to make a sensor, the sensor needs to make a couple readings per hour. So when it is not active it will go into sleep mode. 

    The sensor has data that needs to be stored to work properly. So this data has to be retained when the chip is off.

    Now from what I understand is that normally the Linker puts all data in code on a "random" place in memory and I don't have control over where it is placed, so I need to seperate a section of RAM where the Linker does not put anything but when I need data to be retained I can place it there.

    I am using the SES workspace.

    This is my plan:

    - Open linker file

    - Split the RAM partition into 2 partitions.

    - 1 partition the Linker can touch, and the new partition where I can put specific data in that needs to be retained.

    - Place specific data in the partition that has been added (another question/problem that i need to solve).

    Questions:

    Where do I find the Linker file where I can edit the partitions?

    When I edit the existing partition and make a new one, do I need to keep something in mind?

    I hope that you can help me.

  • Chriis said:
    Where do I find the Linker file where I can edit the partitions?

    You can do it in flash_placement.xml. It is not a very obvious name to find RAM partition configurations...

    Chriis said:
    When I edit the existing partition and make a new one, do I need to keep something in mind?

    To be honest, I don't do this that often to answer this. I will ask my colleagues if they have any opinions and get back to you tomorrow or this Wednesday.

    One thing comes to mind, is that when your project has a bootloader. The bootloader i its own application and has its own idea of what on RAM it can touch. So, if you want the bootloader to not touch your region, you also have to update the partition configurations in the bootloader project.

  • Ok, thanks for the help.

    How do I find this bootloader program so I can edit it?

    Any suggestions from your colleague would be appreciated :)

  • In the nRF5 SDK, the bootloader is a separated application in charge of booting and DFU. The nRF5 SDK's bootloader solutions are documented here: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_bootloader_modules.html.

    My colleague does not have any additional input regarding the adding of partition itself, but he notices a few things I missed in the information you have given me.

    If you are planning to store the sensor data once and wake up every few hours, here are a few things to note:

    • You can also store the sensor data to flash memory using the Flash Data Storage (FDS) library.
    • Since you are worried about the application writing data over your sensor data, I think you might be planning to put the device into System OFF mode. Please note that in System OFF, you cannot run the RTC or TIMER peripherals to wake the device up regularly.

    Also, could you please elaborate better on your concern regarding the linker putting data randomly over your region?

    As far as static memory allocation goes, the linker decides where a variable stays during compile time. That means that after you build your project and the linker put your sensor data on address 0xabcd_ff00, then it will always be on that address. Once you program the device, your data will always be on RAM address 0xabcd_ff00 whether you run it through power cycles or putting it to sleep.

    Could you be thinking about non-initialized RAM section instead of just simply a dedicated RAM section?

    Finally, since you seem to be just starting your project, please know that the nRF5 SDK is now in maintenance mode, and we recommend new projects to use the nRF Connect SDK instead.

    Of course, if you have a strong reason to use the nRF5 SDK, such as familiarity vs. project timeline, we would still be happy to support you with that.

Related