noinit section at a specific address

We're using a noinit section of ram to store a "reboot reason" if/when we need to do a SW reset (i.e. in a watchdog handler).

This works as expected, we set the reboot reason before calling sys_reboot(), and then read it out after the reboot.

However, we would like to allocate a specific memory address to this noinit-section, this to make it fixed across e.g. a FOTA.
As we see it now, the noinit section is laid out in between the static memory address range, and is prune to be moved when changing the the code (between FW versions).
This might cause erroneous values to be read at first boot after FOTA.

Obviously we should change the linker config file, but this is generated by CMake/west, how should we "give input" here?

BR

Alf

Parents
  • Hello Alf, 

    I will have a look at your case and get back to you within Thursday.

    Kind regards,
    Øyvind

  • Sorry for the late reply, Alt. What version of the nRF Connect SDK are you working on?

    From your description it sounds like you need to configure a static configuration in the Partition Manager.You can use pm.yml from the original project and copy this to the new FOTA image. Rename this file to pm_static.yml. 

    Can you provide more details if this is not the case?

    Thanks! 

    Kind regards,

    Øyvind

  • Hi Øyvind, and thanks for detailing!

    We're running SDK v2.0.2 currently.

    The code for declaring the reboot_reason variable is this:

    /**
     * @brief Reboot reason stored in noinit RAM between reboots
     */
    static uint32_t reboot_reason_stored __attribute__((section(".noinit")));
    

    And this works, the reboot_reason variable is not cleared between reboots.

    I've read through you recommended doc, and have now put this section into the pm_static.yml:

    # RAM
    noinit_sram:
        address: 0x20000000
        size: 32
        region: sram_primary
    
    

    This seems to work as expected, it is now created a separate region (0x20000000 - 0x20000020), but how to "connect" the .noinit section (in the code) to the noinit_sram region?

    I cannot seem to find any good examples (in the doc) for this, are you able to point me in the right direction?

    TIA

    -Alf

Reply
  • Hi Øyvind, and thanks for detailing!

    We're running SDK v2.0.2 currently.

    The code for declaring the reboot_reason variable is this:

    /**
     * @brief Reboot reason stored in noinit RAM between reboots
     */
    static uint32_t reboot_reason_stored __attribute__((section(".noinit")));
    

    And this works, the reboot_reason variable is not cleared between reboots.

    I've read through you recommended doc, and have now put this section into the pm_static.yml:

    # RAM
    noinit_sram:
        address: 0x20000000
        size: 32
        region: sram_primary
    
    

    This seems to work as expected, it is now created a separate region (0x20000000 - 0x20000020), but how to "connect" the .noinit section (in the code) to the noinit_sram region?

    I cannot seem to find any good examples (in the doc) for this, are you able to point me in the right direction?

    TIA

    -Alf

Children
Related