Commit Graph

473 Commits

Author SHA1 Message Date
radek.tandler
40f25003b4 fix(test_apps_bootloader): Pre-alocate the security provider lock before evaluating mem leaks 2026-09-01 12:53:21 +03:00
Konstantin Kondrashov
b4dd9878f7 fix(test_apps_bootloader): Change type of actual_leak_threshold to ssize_t 2026-09-01 12:53:21 +03:00
Martin Vychodil
fac7e73de7 Merge branch 'bugfix/nvs-debugdump-check-readentry' into 'master'
fix(nvs_flash): check readEntry return in debugDump

Closes IDF-11759

See merge request espressif/esp-idf!51527
2026-08-21 18:46:57 +08:00
radek.tandler
f16d3f3cf6 docs(nvs_flash): correct public API docs for error code
-align nvs.h / nvs_handle.hpp Doxygen with the implementation: fix return codes
-guard nvs_open against a NULL out_handle
2026-08-19 15:25:12 +02:00
sonika.rathi
5394a30873 docs(nvs_flash): add C++ NVS handle API documentation
Closes https://github.com/espressif/esp-idf/issues/10283
2026-08-13 15:42:18 +08:00
Ashish Sharma
8589d9df25 fix(build): prepare dependents for bootloader_support dropping mbedtls
bootloader_support is about to stop pulling mbedtls (and app_update) into
every build graph, so components and apps that relied on those transitive
edges must own their dependencies

Closes https://github.com/espressif/esp-idf/issues/18072
Related https://github.com/espressif/esp-idf/issues/18778
2026-08-12 08:39:18 +05:30
sonika.rathi
0dfb4ac777 fix(nvs_flash): check readEntry return in debugDump 2026-08-11 11:43:53 +02:00
Martin Vychodil
036cee4e6a Merge branch 'bugfix/nvs-initialize-accumulated-crc32' into 'master'
fix(nvs_flash): initialize accumulatedCRC32 in cmpItem

Closes IDF-15810

See merge request espressif/esp-idf!51068
2026-07-30 16:37:03 +08:00
sonika.rathi
447a364cb2 fix(nvs_flash): erase handle before delete on deinit 2026-07-27 09:26:49 +02:00
sonika.rathi
ff13da5e6c fix(nvs_flash): delete leftover handles on partition deinit 2026-07-24 13:21:30 +02:00
sonika.rathi
78e78d7996 fix(nvs_flash): initialize accumulatedCRC32 in cmpItem 2026-07-22 10:45:05 +02:00
sonika.rathi
adebdf1f6e fix(nvs_flash): delete temporary NVSPartition after erase 2026-07-14 13:32:19 +02:00
radek.tandler
60561b6d08 fix(nvs_flash): fixed cleanup after nvs_set_blob failed on ESP_ERR_NVS_NOT_ENOUGH_SPACE
- fixed identification of blob parts to be cleaned by using right starting chunk index
  - improved localisation of blobs for cases where some of pages get reclaimed
  - created host test cases covering the edge cases above
2026-07-14 10:01:23 +02:00
Martin Vychodil
f0887bcf87 Merge branch 'contrib/github_pr_18772' into 'master'
docs(nvs): remove unused return code (GitHub PR)

Closes IDFGH-17878

See merge request espressif/esp-idf!50560
2026-07-09 21:14:32 +08:00
Aditya Patwardhan
5ee87f7b2c Merge branch 'fix/nvs-encrypted-partition-destructor-zeroize' into 'master'
fix(nvs_flash): zeroize XTS contexts when encrypted partition is destroyed

See merge request espressif/esp-idf!47585
2026-07-06 14:29:27 +05:30
Richard Allen
1efc077ed9 docs(nvs): remove unused return code
nvs_get_i8() cannot return ESP_ERR_NVS_INVALID_LENGTH,
as a length argument is not present.
2026-06-29 14:59:08 -05:00
sonika.rathi
e9315fa19f fix(nvs_flash): normalize nvs partition tool CLI output 2026-06-22 10:42:51 +02:00
sonika.rathi
0785165195 fix(nvs_flash): narrow GNU analyzer suppression to nvs_cxx_api 2026-06-02 09:53:10 +02:00
Guillaume Souchere
d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00
Sudeep Mohanty
301eeba878 Merge branch 'task/buildv2_hygiene_and_dep_declarations' into 'master'
fix(components): generic dep-declaration and scope-leakage hygiene exposed by cmakev2

See merge request espressif/esp-idf!48739
2026-05-26 10:18:22 +02:00
Aditya Patwardhan
65e77bcfd3 fix(nvs_flash): zeroize XTS contexts when encrypted partition is destroyed
NVSEncryptedPartition held two XTS_CONTEXT members (mEctxt, mDctxt) for
encryption / decryption. Their AES round keys are derived from the NVS
encryption key (HMAC-derived or plaintext from nvs_keys partition) and
therefore are sensitive secrets.

The destructor was empty, so when the NVS encrypted partition object
was destroyed -- on nvs_flash_deinit_partition(), on initialization
errors, and on any other teardown path -- the XTS round keys were left
in DRAM until the freed object's memory happened to be overwritten by
a later allocation. A subsequent stack/heap leak primitive would
recover the AES key from those bytes.

Fix:
* Initialize both XTS contexts in the constructor so the destructor's
  free path is always safe (previously xts_init was only called in
  init(); destruction before init() would have run xts_free on an
  uninitialized struct).
* Provide a real destructor that calls XTS_FUNC(xts_free) on both
  contexts, which performs mbedtls_platform_zeroize / esp_aes_xts free
  semantics on the underlying AES contexts.
2026-05-25 21:58:24 +05:30
Jiang Jiang Jian
90ec41a9f7 Merge branch 'feat/support_rom_psa_mbedtls' into 'master'
feat(mbedtls): enable ESP32-C2(Rev2.0) ROM mbedTLS crypto for PSA

Closes IDF-15012

See merge request espressif/esp-idf!48211
2026-05-22 11:24:42 +08:00
Sudeep Mohanty
07af6ddcf7 fix(host_test): use ${project_elf} variable and keyword link form
Three host_test CMakeLists.txt files relied on idioms tied to a
specific build system layout. Make them portable:

- spiffs/host_test and esp_partition/host_test/partition_api_test
  passed a hard-coded "<project>.elf" target name to add_dependencies().
  Use ${project_elf}, the canonical variable that resolves to the live
  executable target name in either build system.

- nvs_flash/host_test/nvs_page_test linked --coverage using the plain
  signature of target_link_libraries. CMake forbids mixing plain and
  keyword signatures on the same target; the component library link
  already uses the keyword form. Switch the --coverage link to the
  keyword signature.
2026-05-21 10:05:48 +02:00
Jiang Guang Ming
42674c2f95 fix(mbedtls): support ROM mbedTLS crypto in bootloader 2026-05-20 14:15:22 +08:00
Jiang Guang Ming
d5a712f1f8 feat(mbedtls): enable ROM mbedTLS pytest with esp32c2 rev2.0 2026-05-20 14:15:19 +08:00
sonika.rathi
44e2d244e8 fix(nvs_flash): scope NVS unity tests to correct CI configs 2026-05-19 15:09:31 +02:00
Radek Tandler
5c8f5fc66d Merge branch 'feature/nvs_fd_support' into 'master'
feat(nvs_flash): Added support for storing flash and double types

Closes IDFGH-9857

See merge request espressif/esp-idf!47045
2026-04-15 11:03:57 +02:00
Adam Múdry
749c446a7e feat(esp_partition): Add esp_partition_flash_binary() CMake function
Add a new CMake function esp_partition_flash_binary() that provides a
unified API for registering partition data binaries to be flashed. It
replaces the direct esptool_py_flash_target calls scattered across
components (spiffs, fatfs, nvs_flash) with a single function that:

- Resolves partition offset from the partition table automatically
- Determines encryption requirements (auto-detect or ALWAYS_PLAINTEXT)
- Creates per-partition flash targets (e.g. idf.py <partition>-flash)
- Optionally includes the binary in `idf.py flash` via FLASH_IN_PROJECT

On the linux target, the function registers binaries for pre-loading
into the emulated flash. A build-time manifest (linux_flash_data.txt)
is generated via file(GENERATE), and partition_linux.c reads it at
runtime to copy each binary into the memory-mapped flash buffer at
the correct offset.

The partition_ops example is updated to use the new function and
includes a custom_partition with pre-built data to demonstrate the
full workflow, including on the linux target.
2026-04-10 15:22:50 +02:00
radek.tandler
a5443bbb94 feat(nvs_flash): Added support for storing flash and double types
- added backward compatibility test for unknown NVS entry types
 - axtended documentation with the support of double and float
2026-03-31 19:02:43 +02:00
harshal.patil
8bd87b67e2 fix(nvs_flash): Use h/w accelerated AES-ECB for XTS-AES operations 2026-02-11 15:24:03 +05:30
Chen Ji Chang
7a8a5d8852 Merge branch 'test/parlio_flash_enc_test' into 'master'
test(parlio,rmt,lcd): add virtual flash encryption test

Closes IDF-15064, IDF-15065, and IDF-15069

See merge request espressif/esp-idf!45006
2026-02-06 19:26:22 +08:00
radek.tandler
d50c7b4b6b feat(nvs_flash): Added purging of erased items at namespace level
- Added new option NVS_READWRITE_PURGE for nvs_open. All update and erase operations of
    the handle are wiping out the content erased items on top of just marking them erased.
  - Added new API call nvs_purge_all allowing to wipe out the existing erased items
    of the handle.
2026-02-05 11:07:43 +01:00
Chen Jichang
b8c527a87c refactor(flash_enc): move esp_flash_encryption_enabled() to efuse component 2026-02-05 11:42:08 +08:00
igor.udot
4c26ab876b ci: update build-test-rules to use common_components 2026-01-23 10:14:09 +08:00
radek.tandler
4806d2e57f feat(nvs_flash): Added option enabling verification of flash erase operation 2026-01-09 11:14:08 +08:00
Radek Tandler
0fa490524a Merge branch 'bugfix/nvs_flash_space_reclaim' into 'master'
fix(nvs_flash): Fixed sequence of page state changes to allow correct recovery when power is interrupted

See merge request espressif/esp-idf!44454
2026-01-08 13:44:28 +01:00
Ashish Sharma
5663e93298 feat: migrates nvs_flash to PSA APIs 2025-12-30 09:31:49 +05:30
radek.tandler
f0c7d9b6c6 fix(nvs_flash): Fixed order of page state change to allow recovery 2025-12-22 14:57:57 +01:00
C.S.M
f405e51784 ci(esp32s31): Add ci build test for esp32s31 2025-12-11 15:17:15 +08:00
radek.tandler
bbfe8e7492 refactor(nvs_flash): NVS Host tests cleaned-up and test cases commented
- Host test were refactored to allow for BDL and non-BDL NVS implementation
- Introduceed `NVSPartitionTestHelper` class replacing `PartitionEmulationFixture`
- Refactored all tests to use `NVSPartitionTestHelper` instead of legacy emulation fixture
- Removed legacy `PartitionEmulationFixture` and `PartitionEmulationFixture2` classes
- Removed `TEMPORARILY_DISABLED` macro usage by reducing partition size in applicable tests
- Enhanced test coverage and readability with comments and validation steps for each TC
- Added utility functions for partition stats tracking, file loading, and erase count check
2025-12-02 15:32:14 +01:00
radek.tandler
191ac74dd0 feat(nvs_flash): Added support for Block Data Layer storage provider
- BDL provider can be enabled vor NVS in the menuconfig option NVS_BDL_STACK
- Hierarchy of Partition class tree was adjusted and all operations were documented
- Class Partition is now derived from intrusive_list_node and ExceptionlessAllocable
- Class NVSPartition implements only the dual support for esp_partition and BDL
- Class NVSEncryptedPartition implements only encryption related extensions
2025-12-02 15:32:10 +01:00
Radek Tandler
207199a2bb Merge branch 'refactor/nvs_header_cleanup' into 'master'
Cleanup of NVS copyright notices, header pragma once and NVS related constants

See merge request espressif/esp-idf!42353
2025-10-02 15:08:45 +02:00
radek.tandler
801091c079 refactor(nvs_flash): NVS constants were consolidated
- Constant definitions depending on spi_flash were added to nvs_constants
2025-10-02 12:39:37 +02:00
radek.tandler
a11c30a3e3 refactor(nvs_flash): Adjusted copyright notices and header file pragma once 2025-10-02 12:35:50 +02:00
radek.tandler
1c6e2d2f88 fix(nvs_flash): Parsing NVS partition containing non ASCII keys 2025-10-02 05:59:14 +02:00
Laukik Hase
f565fc2481 change(nvs_flash): Add a private dependency of the nvs_sec_provider component
- Closes https://github.com/espressif/esp-idf/issues/17256
2025-09-19 10:17:46 +05:30
Laukik Hase
f60bcaaa4d feat(nvs_flash): Added an API to deregister the NVS security scheme context 2025-09-19 10:17:45 +05:30
radek.tandler
96f4f78054 ci(nvs_flash): Enabled nvs_host_test in ci 2025-09-16 20:45:25 +02:00
radek.tandler
ccb455fc63 fix(nvs_flash): Fixed host test case when legacy compatibility mode is enabled 2025-09-16 20:45:25 +02:00
radek.tandler
0f5c963a03 fix(nvs_flash): Host test adopted to the new clang initializer rules 2025-09-16 20:45:08 +02:00