Commit Graph

135 Commits

Author SHA1 Message Date
radek.tandler
b937cb7549 fix(storage/nvs): Fixed hadling of inconsistent values in NVS entry header
feat(storage/nvs): Added test cases for damaged entries with correct CRC
2024-08-20 10:57:24 +02:00
radek.tandler
ffaf1d2968 feat(nvs_flash): Added Kconfig option contolling NVS heap allocation source
NVS configuration is extended with Kconfig option controlling RAM area for
NVS heap allocation. Either Internal RAM or SPIRAM can be chosen.
Tests were extended to check memory consumption from Internal and SPIRAM pool with respect
to the Kconfig option chosen.
Documentation was extended with notes related to NVS behavior in various situations.
2024-06-06 08:25:51 +02:00
Adam Múdry
8e43afef3b fix(nvs): Fix possible collision with app trace sysview defines
Global.h defines U8, I8, U16, etc. symbols, which are also used in NVS
as a part of custom enum class and this can cause a compilation error
during macro expansion, when sysview is enabled and FreeRTOS.h is included in NVS
2024-04-12 13:46:51 +02:00
Ivan Grokhotkov
10cc15b150
fix(storage): applied spelling fixes by codespell pre-commit hook 2024-03-28 13:00:54 +01:00
radek.tandler
508d9a6a22 fix(nvs): Fixed Page::findItem performance degradation
Wrong condition gating the hash map use causing performance degradation was corrected

The condition enabling use of hash map when page is searched for Item was modified
to correct the bug introduced by commit addressing delete of any BLOB_INDEX Items.
This correction returns the performance of findItem to the state before previous change.
2024-03-07 19:47:33 +01:00
radek.tandler
fc6951e193 fix(nvs): Improved lockig mechanism for initialization phase 2024-02-24 07:55:32 +01:00
radek.tandler
635e6b154e fix(nvs): eraseMultiPageBlob to robustly delete all related BLOB_DATA records and respect VER_ANY 2024-02-24 07:55:32 +01:00
radek.tandler
cad09ea461 fix(nvs): corrected findItem to return BLOB_DATA when chunkIndex = CHUNK_ANY 2024-02-24 07:55:22 +01:00
radek.tandler
d879ec5248 fix(nvs): added check and erase of mismatched BLOB_DATA on init 2024-02-22 15:15:10 +01:00
Ivan Grokhotkov
5b53fb07fb fix(nvs): prevent out of bounds write if blob data is inconsistent 2024-02-22 15:15:10 +01:00
radek.tandler
8740888967 feat(nvs_flash): Added function nvs_find_key
Closes https://github.com/espressif/esp-idf/issues/12155
2023-12-08 17:12:00 +01:00
Adam Múdry
e151184da7 refactor: Remove -Wno-format from storage related components 2023-10-22 17:56:41 +00:00
Adam Múdry
ab1eb37fe8 feat(partition_table): Add read-only partition flag and functionality 2023-10-11 00:01:05 +02:00
radek.tandler
4f659b70e1 fix(nvs_flash): fixed failing nvs_page test 2023-09-26 15:05:20 +00:00
radek.tandler
e8992f500c fix(nvs_flash): nvs_set with same key and different data type
Function now always rewrites old value under same key
regardless existing data type. Users requiring old API behaviour
can enable it by kconfig option CONFIG_NVS_LEGACY_DUP_KEYS_COMPATIBILITY
2023-09-26 15:05:20 +00:00
radek.tandler
f693b78f93 feature(nvs_flash) : added support iteration over namespace by index - review changes 2023-08-29 16:05:02 +02:00
Ivan Grokhotkov
92ff04ebea nvs: use 'handle' argument name for consistency 2023-08-29 13:59:34 +02:00
Cody P Schafer
f2af1c5305 nvs: support iteration over namespace by index
Users of the nvs API are likely to have `nvs_handle_t` in all cases, but
not all of them carry around the partition name and namespace name (as
they aren't needed after creating an `nvs_handle_t`).

Allow this common case to use nvs iteration without them tracking
additional data by using the `nvs_handle_t` to locate the namespace
index and the partition name by introducing an alterate to
`nvs_entry_find` called `nvs_entry_find_in_handle`, which operates
similarly except that it is given a `nvs_handle_t` instead of partition
and namespace strings.

This is somewhat more limited than the `nvs_entry_find` API as one
cannot examine all keys in a given partition.
2023-08-29 13:59:34 +02:00
radek.tandler
3ffb8f8ffd nvs: nvs_get_stats fixed test, improved comment 2023-08-08 08:43:19 +02:00
radek.tandler
ac6c03fad1 change(nvs_flash): nvs_get_stats extended, API documentation improved 2023-08-08 08:43:19 +02:00
KonstantinKondrashov
e72061695e all: Removes unnecessary newline character in logs
Closes https://github.com/espressif/esp-idf/issues/11465
2023-06-09 03:31:21 +08:00
Laukik Hase
c1bed366ba
nvs_flash: Add support for HMAC-based NVS encryption keys protection scheme
- This features allows the NVS encryption keys to be derived and protected using
  the HMAC peripheral. Since the encryption keys are derived at runtime, they
  are not stored anywhere in the flash and hence this feature does not require
  a separate `nvs_keys` partition.
2023-05-23 13:55:52 +05:30
Jakob Hasse
e6ca481623 bugfix(nvs_flash): fixed potential memory leak in nvs::Storage::init() 2022-12-15 15:37:21 +08:00
Jakob Hasse
91f04aa877 refactor(nvs): custom allocator for all objects allocated in NVS 2022-12-05 18:59:33 +01:00
Ivan Grokhotkov
7a1e19edf1
nvs_flash: replace strncpy + manual null termination with strlcpy
Since libbsd is now a build dependency on Linux, strncpy can be
replaced with the safer and less verbose strlcpy.
2022-08-17 12:20:36 +02:00
Ivan Grokhotkov
bee241b0e2
nvs_flash: remove leftover ESP_ERROR_CHECKS
Similar to the asserts, these are replaced by error checks.
2022-08-17 12:20:36 +02:00
Ivan Grokhotkov
02661081be
nvs_flash: make nvs_flash_init usable for Linux target
Since the partition API is now supported for Linux target builds,
this function can now be used.
2022-08-17 12:20:36 +02:00
Ivan Grokhotkov
bfb6f31872
nvs_flash: remove unnecessary check that the data pointer is in DROM
spi_flash driver knows how to write data from cache (DROM or PSRAM)
into flash, so the extra check in nvs_flash is unnecessary.
Besides, the hardcoded address limit (0x3ff00000) is wrong for some
of the newer chips.
2022-08-17 12:20:36 +02:00
Ivan Grokhotkov
08e41973f0
nvs_flash: update intrusive_list for compatibility with C++17
std::iterator is deprecated since C++17, the code produces a warning
when compiled with clang and libc++.
2022-08-17 12:20:36 +02:00
Cao Sen Miao
a690a87829 spi_flash: Remove legacy spi_flash drivers 2022-07-01 11:01:34 +08:00
Ivan Grokhotkov
87180907f7 Merge branch 'bugfix/nvs_part_ptr_wrong_init' into 'master'
bugfix (nvs_flash): Fix nvs_flash_init_partition_ptr

Closes IDFGH-7503 and IDFGH-7152

See merge request espressif/esp-idf!18503
2022-06-23 21:23:39 +08:00
Djordje Nedic
bbc3add0e3 tools: overhaul csv handling for mfg_gen and nvs_partition_gen
This fixes the issue where multiline strings and strings with delimiters inside the nvs input csv file were incorrectly parsed, and adds back the ability to add comment lines anywhere in the CSV file.

The issue stems from the move away from the python built in csv module to manual parsing, which was made after moving away from using the csv module to parse mfg data.

This reverts back to using the csv module for parsing and writing csv data in both mfg_gen and nvs_partition_gen, fixes the original issue in mfg_gen and improves code quality which makes the code more readable and maintainable.

Closes https://github.com/espressif/esp-idf/issues/7175
2022-06-15 12:31:49 +00:00
ioio
a759e00958 bugfix (nvs_flash): Fix nvs_flash_init_partition_ptr
Added unit test case.

Closes https://github.com/espressif/esp-idf/pull/8755

Signed-off-by: Jakob Hasse <jakob.hasse@espressif.com>
2022-06-15 10:38:56 +08:00
Anton Maklakov
25cee26784 Merge branch 'bugfix/storage-warnings' into 'master'
nvs: minor warning fixes

See merge request espressif/esp-idf!18313
2022-05-31 13:46:13 +08:00
Anton Maklakov
b3a6c3bcb5 nvs: suppress -Wstringop-truncation warning 2022-05-30 13:11:25 +07:00
Jakob Hasse
ad184e979a refactor (nvs)!: New interface for iterator functions
Closes https://github.com/espressif/esp-idf/issues/7826

* nvs_entry_find(), nvs_entry_next() and nvs_entry_info()
  return error codes now
* nvs_entry_find() and nvs_entry_next() access/modify iterator via
  parameters, instead of returning an new iterator.

Added appropriate documentation in Chinese and English
2022-05-30 09:28:42 +08:00
Matus Fabo
58cca07104 add: Kconfig assert or errorcode option
add: private include header
add: macro encapsulation for assertion or error check
add: ESP_FAIL return code documentation in public headers
change: replaced all assertions by NVS_ASSERT_OR_RETURN macro
change: few internal function return values from void to esp_err_t
change: ESP_ERR_NVS_VALUE_TOO_LONG macro comment
2022-05-28 20:29:05 +02:00
Jakob Hasse
4c8c2a8079 bugfix (nvs): Fixed issues found by Coverity
*  Fixed potential memory leak
*  Fixed wrong strncpy usage
*  Fixed potential out of bounds access
2022-01-27 19:30:58 +08:00
Michael (XIAO Xufeng)
43643716a2 bugfix (nvs): fixed wrong pointer check 2021-12-13 10:42:45 +08:00
Jakob Hasse
84d184bdb0 Merge branch 'bugfix/nvs_corrupted_storage_crashes_app' into 'master'
[NVS]: fix crashes from entry state 1

See merge request espressif/esp-idf!14548
2021-08-06 09:14:21 +00:00
Jakob Hasse
4dd88329c1 [esp_rom]: Partially buildable for linux
The following files have been ported:
* esp_rom_crc.h
* esp_rom_sys.h
* esp_rom_efuse.h (mostly no-ops)
* esp_rom_md5.h

Integrated Linux-based rom implementation into log
and NVS component.

Added brief host tests for ROM to ensure basic
consistency on Linux.

Added ROM printf host unit tests.

Temporarily added reset reason for Linux in ROM.
2021-08-03 12:03:24 +08:00
Jakob Hasse
de6b54de66 [nvs_flash]: Entries with state == 1 don't crash 2021-07-30 18:33:27 +08:00
Anton Maklakov
e5faf4f924 ci: fix test_build_system* fails 2021-06-07 18:48:38 +07:00
Jakob Hasse
d52a21de5c Random NVS fixes
* Checking Lock::init() now
* fixed typos in nvs_flash.h
* Added missing parameter checks in nvs encryption
  function

* Closes IDF-1462
* Closes IDF-2900
2021-03-08 14:41:53 +08:00
Angus Gratton
d6f4d99d93 core system: Fix warnings in compilation when assertions are disabled
Adds a CI config for hello world that sets this, to catch future regressions
2021-03-03 10:26:57 +11:00
Jakob Hasse
897e81f765 [doc]: elaborated nvs encryption comments in nvs 2021-02-04 15:27:37 +08:00
negativekelvin
d625310ef4 Fix nvs_flash_generate_keys
Merges https://github.com/espressif/esp-idf/pull/6478
2021-02-04 15:27:37 +08:00
Aditya Patwardhan
a02be97fda nvs_flash: Modify the default NVS initialization API with internal nvs encryption
handling (only when nvs encryption is enabled)
    * NVS Encryption will now be turned on by default with flash encryption
    * Updated the flash encryption example to shocase NVS encryption
    along with information on how to configure and use NVS encryption
    * Updated respective test case
    * Added two partition tables for NVS encryption
     i) Table 1- Single factory app, no OTA, encrypted NVS
     ii) Table 2- Factory app, Two OTA, encrypted NVS
2021-01-20 11:12:14 +00:00
Ivan Grokhotkov
45afa158ff Merge branch 'bugfix/nvs_str_cmp' into 'master'
NVS: fix string comparison

Closes IDF-2476

See merge request espressif/esp-idf!11523
2020-12-24 18:28:29 +08:00
Jakob Hasse
7b223c3337 NVS: fix string comparison
Closes IDF-2476
2020-12-16 13:53:17 +08:00