Skip to content

Commit f9476db

Browse files
alxelaxnordicjm
authored andcommitted
emds: fix writing buffer size usage
Commit: * adds option to configure rram writing buffer size; * fixes writing buffer length usage; * fixes emds test measured writing performance (it uses now value close to datasheet) Signed-off-by: Aleksandr Khromykh <[email protected]>
1 parent e917607 commit f9476db

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

subsys/emds/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ config EMDS_FLASH_TIME_BASE_OVERHEAD_US
7575
datasheet.
7676
For RRAM-based persistent memory driver, use ERASEPROTECT and disregard the SOC_FLASH_NRF_PARTIAL_ERASE_MS parameter.
7777

78+
if SOC_FLASH_NRF_RRAM
79+
80+
config EMDS_RRAM_WRITE_BUFFER_SIZE
81+
int "Internal write-buffer size"
82+
default 1
83+
range 1 32
84+
help
85+
Number of 128-bit words.
86+
Maximum buffer size can be configured to the value of 32 (128-bit words).
87+
88+
endif # SOC_FLASH_NRF_RRAM
89+
7890
module = EMDS
7991
module-str = emergency data storage
8092
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

subsys/emds/emds_flash.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#define RRAM_START DT_REG_ADDR(RRAM)
2121
#define RRAM_SIZE DT_REG_SIZE(RRAM)
2222
#define EMDS_FLASH_BLOCK_SIZE DT_PROP(RRAM, write_block_size)
23-
#define WRITE_BUFFER_SIZE NRF_RRAMC_CONFIG_WRITE_BUFF_SIZE_MAX
23+
#define WRITE_BUFFER_SIZE CONFIG_EMDS_RRAM_WRITE_BUFFER_SIZE /* in 128-bits words */
24+
#define WRITE_LINE_SIZE 16 /* In bytes, one line is 128 bits. */
25+
#define WRITE_BUFFER_SIZE_IN_BYTES (WRITE_BUFFER_SIZE * WRITE_LINE_SIZE)
2426
#else
2527
#include <nrfx_nvmc.h>
2628
#define FLASH DT_INST(0, soc_nv_flash)
@@ -145,7 +147,7 @@ static void commit_changes(size_t len)
145147
return;
146148
}
147149

148-
if ((len % WRITE_BUFFER_SIZE) == 0) {
150+
if ((len % WRITE_BUFFER_SIZE_IN_BYTES) == 0) {
149151
/* Our last operation was buffer size-aligned, so we're done. */
150152
return;
151153
}

tests/subsys/emds/emds_flash/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define RRAM DT_INST(0, soc_nv_flash)
2323
#define EMDS_FLASH_BLOCK_SIZE DT_PROP(RRAM, write_block_size)
2424
#define EXPECTED_STORE_TIME_BLOCK_SIZE (400)
25-
#define EXPECTED_STORE_TIME_1024 (3000)
25+
#define EXPECTED_STORE_TIME_1024 (6200)
2626
#else
2727
#define FLASH DT_INST(0, soc_nv_flash)
2828
#define EMDS_FLASH_BLOCK_SIZE DT_PROP(FLASH, write_block_size)

0 commit comments

Comments
 (0)