fs/nvs: Switch to use flash_flatten instead of flash_erase
The NVS currently requires explict erase capability of a device to work, so usage of flash_erase has been replaced with flash_flatten. There has been additional LOG_WRN added to warn user that NVS may not efficiently work with device that do not really have erase. Currently NVS relies on devices that require erase. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
64ccfb0479
commit
bf7d25117a
3 changed files with 15 additions and 1 deletions
|
@ -207,7 +207,18 @@ ZTEST_F(nvs, test_nvs_corrupted_write)
|
|||
&flash_max_write_calls);
|
||||
stats_walk(fixture->sim_stats, flash_sim_write_calls_find, &flash_write_stat);
|
||||
|
||||
#if defined(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE)
|
||||
*flash_max_write_calls = *flash_write_stat - 1;
|
||||
#else
|
||||
/* When there is no explicit erase, erase is done with write, which means
|
||||
* that there are more writes needed. The nvs_write here will cause erase
|
||||
* to be called, which in turn calls the flash_fill; flash_fill will
|
||||
* overwrite data using buffer of size CONFIG_FLASH_FILL_BUFFER_SIZE,
|
||||
* and then two additional real writes are allowed.
|
||||
*/
|
||||
*flash_max_write_calls = (fixture->fs.sector_size /
|
||||
CONFIG_FLASH_FILL_BUFFER_SIZE) + 2;
|
||||
#endif
|
||||
*flash_write_stat = 0;
|
||||
|
||||
/* Flash simulator will lose part of the data at the end of this write.
|
||||
|
|
|
@ -6,6 +6,9 @@ tests:
|
|||
filesystem.nvs.0x00:
|
||||
extra_args: DTC_OVERLAY_FILE=boards/qemu_x86_ev_0x00.overlay
|
||||
platform_allow: qemu_x86
|
||||
filesystem.nvs.sim.no_erase:
|
||||
extra_args: CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE=n
|
||||
platform_allow: qemu_x86
|
||||
filesystem.nvs.cache:
|
||||
extra_args:
|
||||
- CONFIG_NVS_LOOKUP_CACHE=y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue