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

Why doesn't Device State Manager allow to increase the number of entries?

The Device State Manager (DSM) will erase the flash if any of the following parameters have changed since last boot.

  • DSM_NONVIRTUAL_ADDR_MAX
  • DSM_VIRTUAL_ADDR_MAX
  • DSM_APP_MAX
  • DSM_DEVICE_MAX
  • DSM_SUBNET_MAX

I agree that it can cause problem if these have decreased in size but is there really an issue if they have increased?

For example, after deploying a node it becomes clear that the number of application keys weren't sufficient and thus DSM_APP_MAX must be increased. This would erase the DSM flash page which isn't actually required as the old entries would fit in the new firmware's arrays as they are larger. The indexes will remain the same.

Thus, is there an issue of changing dsm_flash_config_load() according to the following patch.

diff --git a/mesh/access/src/device_state_manager.c b/mesh/access/src/device_state_manager.c
index fae2bd0..ee05966 100644
--- a/mesh/access/src/device_state_manager.c
+++ b/mesh/access/src/device_state_manager.c
@@ -1795,11 +1795,11 @@ bool dsm_flash_config_load(void)
         return true;
     }
 
-    if (metainfo.max_addrs_nonvirtual != DSM_NONVIRTUAL_ADDR_MAX ||
-        metainfo.max_addrs_virtual != DSM_VIRTUAL_ADDR_MAX ||
-        metainfo.max_appkeys != DSM_APP_MAX ||
-        metainfo.max_devkeys != DSM_DEVICE_MAX ||
-        metainfo.max_subnets != DSM_SUBNET_MAX)
+    if (metainfo.max_addrs_nonvirtual > DSM_NONVIRTUAL_ADDR_MAX ||
+        metainfo.max_addrs_virtual > DSM_VIRTUAL_ADDR_MAX ||
+        metainfo.max_appkeys > DSM_APP_MAX ||
+        metainfo.max_devkeys > DSM_DEVICE_MAX ||
+        metainfo.max_subnets > DSM_SUBNET_MAX)
     {
         /* The area is built with different metadata, reset it */
         reset_flash_area();

Thanks.

Parents Reply
  • Hi again.

    The problem with allowing this use case is that; if a number of DMS pages get changed as a result of increasing values of DSM_*MAX defines, it will trigger either an assertion in subsequent modules when they see that the flash page metadata is different than expected. Or it may lead to corrupted data loading other modules.
    It is better to plan in advance and allocate more space for a sufficient number of DSM entries.

    Regards,
    Joakim

Children
No Data
Related