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 Reply
  • Hi,

    I will continue to help with this ticket

    Maybe the fw_info library could be useful for you?
    Not directly, but for two reasons:

    The fw_info library finds an unknown place in flash by searching through it all for a magic number.
    Maybe you could use a similar solution to find whawt you are looking for in RAM? Then, it would not matter that it moves.

    Also, the fw_info docs say
    "
    The structure also contains the location of a RAM buffer into which a pointer to a matching EXT_API can be placed before booting. The RAM buffer must not be initialized or otherwise touched when booting the image, to ensure that the value written there before booting is preserved. The EXT_API_REQ helper macro uses the __noinit decorator provided by Zephyr to achieve this.
    "

    Which maybe sound similar to what you have here?

    Regards,
    Sigurd Hellesvik

Children
No Data
Related