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

NRF9160 Persist Ram

Hi,

I am trying to set up a region of RAM to store variables that persist across soft reboots but am unsure how to do it in this environment. I would normally define a region of RAM in the linker script, and store uninitialised variables in it. How do I do that in the zephyr environment for the NRF9160?

Kind regards,

Thomas

Parents
  • Hello Thomas, 

    Just did a quick test here in the Hello World sample, and you should be able to do what you are asking.

    /*
     * Copyright (c) 2012-2014 Wind River Systems, Inc.
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <sys/printk.h>
    #include <power/reboot.h>
    
    u8_t test_array[0x400] __attribute__((section(".noinit")));
    
    void main(void)
    {
    	printk("%u\n", test_array[0]);
    	printk("Hello World! %s\n", CONFIG_BOARD);
    
    	test_array[0]++;
    
    	k_sleep(K_SECONDS(1));
    	sys_reboot(0);
    }
    

    And in the prj.conf add the following:

    CONFIG_REBOOT=y

    This will count one and reboot, count one, and reboot. 

    Let me know how that works for your application. 

    Kind regards,
    Øyvind

  • Thank you Øyvind,

    How do you define a specific region in RAM for it though, like you would in a linker script? Is it the partition conf file that needs changing?

    Kind regards,

    Thomas

  • You don't. This is a dynamic range set automatically by the OS.

    Kind regards,
    Øyvind

Reply Children
Related