Skip to content

Commit

Permalink
emds: Fix size calculation required by emds entries on RRAM
Browse files Browse the repository at this point in the history
The total size required by emds entries calculated more than what is
actually being used. For RRAM, we don't need to align the data with
write block size. We can write as many bytes as we want up to the size
of write block size, thus we don't need to align writes with write
block size.

Signed-off-by: alperen sener <[email protected]>
  • Loading branch information
m-alperen-sener committed Jan 6, 2025
1 parent cac49ac commit 4e28ffd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion subsys/emds/emds.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,28 @@ static int emds_entries_size(uint32_t *size)
*size = 0;

STRUCT_SECTION_FOREACH(emds_entry, ch) {
#if defined CONFIG_SOC_FLASH_NRF_RRAM
/* Data is not required to be alinged with block_size for RRAM */
*size += ch->len;
*size += emds_flash.ate_size;
#else
*size += DIV_ROUND_UP(ch->len, block_size) * block_size;
*size += DIV_ROUND_UP(emds_flash.ate_size, block_size) * block_size;
#endif
entries++;
}

struct emds_dynamic_entry *ch;

SYS_SLIST_FOR_EACH_CONTAINER(&emds_dynamic_entries, ch, node) {
#if defined CONFIG_SOC_FLASH_NRF_RRAM
/* Data is not required to be alinged with block_size for RRAM */
*size += ch->entry.len;
*size += emds_flash.ate_size;
#else
*size += DIV_ROUND_UP(ch->entry.len, block_size) * block_size;
*size += DIV_ROUND_UP(emds_flash.ate_size, block_size) * block_size;
#endif
entries++;
}

Expand Down Expand Up @@ -251,7 +263,6 @@ int emds_prepare(void)
}

(void)emds_entries_size(&size);

rc = emds_flash_prepare(&emds_flash, size);
if (rc) {
return rc;
Expand Down

0 comments on commit 4e28ffd

Please sign in to comment.