With FOTA code included NVS no longer stores values

I've been trying  to use the NVS subsystem along with BLE and FOTA.
I got BLE and NVS working fine.
But if I enable FOTA (just  including the code, not running an update), NVS no longer saves my (single) value. 
I believe I've traced it to the 'storage' partition being used by all.
So I've been trying to enable a second area within the storage partition to separate the NVS information into it's own area:
----- my overlay file to change the partition -----
/delete-node/ &storage_partition;

&flash0 {
partitions {
compatible = "fixed-partitions";
    nvs_partition: partition@f8000 {
        label = "nvs_storage";
        reg = <0x000f8000 0x00002000>;
    };
    storage_partition: partition@fa000 {
        label = "storage";
        reg = <0x000fa000 0x00006000>;
};};};
BUT, when I do this, although zephyr.dts.pre and zephyr.dts show my changes, I get an error message:
error: PM_PM_PM_nvs_storage_ID_LABEL_OFFSET undeclared ...
Any hints on where to go from here?
EDIT:

Here is a short project to illustrate the issue.  Enabling the #define FOTA  causes NVS accesses to fail with ENOENT (no such file/directory).
Then, changing "storage" to "nvs_storage" in the nvs.c file, it will produce the above error during compilation.

Also, regardless of whether FOTA is disabled, after running awhile and then reset, the first several values may fail or be wrong, and then begin working correctly.

Note: I'm running the latest Zephyr 2.0.0 version on the NRF52840. (I have both the nrf8240DK and the nrf9160 with nrf52840)

fota_nvs.zip

  • Hi Caycee, 

    When you compile with FOTA (CONFIG_BOOTLOADER_MCUBOOT=y ? ) in the build folder there will be a file called partitions.yml generated. Could you send us the file ? 


    It's the partitions configuration that partition manager will use to configure the location for primary slot , secondary slot and NVS storage. There could be a chance that there is a conflict here. 


    Note that you can create a file called pm_static.yml to force Partition manager to use the layout you define. 

  • I found this late yesterday..."the partition manager will take over and manage the memory layout once you start doing multi-image builds. This means that the DTS configuration will be ignored.
    Then I realized why my overlay file was not giving me the results I was after.

    After creating a pm_static.yml (never even Looked at any yaml files prior) the NVS finally found its place.

    However, now my main app immediately reboots as soon as BLE attempts to connect to a sensor. Likely a stack problem or buffer overrun, but so far I haven't found out why...

Related