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

Flash Manager entries are padded with random data

When storing entries that aren't multiple of 4 bytes they are padded with random bytes by flash manager.

The problem is that they aren't padded with 1's but rather random data from RAM. This it self isn't a major issue but it's nice to pad with 1 to avoid having random data when looking at flash dumps.

Something along the lines should fix this.

diff --git a/mesh/core/src/flash_manager.c b/mesh/core/src/flash_manager.c
index ea4d2c3..1340f5f 100644
--- a/mesh/core/src/flash_manager.c
+++ b/mesh/core/src/flash_manager.c
@@ -1067,6 +1067,9 @@ fm_entry_t * flash_manager_entry_alloc(flash_manager_t * p_manager,
         p_action->params.entry_data.entry.header.len_words = 1 + ALIGN_VAL(data_length, WORD_SIZE) / WORD_SIZE;
         p_action->p_manager = p_manager;
 
+        /* Ensure no garbage is written to flash */
+        p_action->params.entry_data.entry.data[p_action->params.entry_data.entry.header.len_words - 2] = UINT32_MAX;
+
         return &p_action->params.entry_data.entry;
     }
 }

SDK For Mesh v3.2.0.

Thanks

Related