Commit Graph

462 Commits

Author SHA1 Message Date
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
radek.tandler
233a76e808 fix(nvs_flash): Fixed overwrite of V1 BLOB when legacy compatibility mode is in place 2025-09-15 16:16:28 +02:00
Alexey Lapshin
9281e78381 change(esp_libc): rename newlib component to esp_libc 2025-09-09 22:00:44 +08:00
Marek Fiala
9d35d63651 feat(cmake): Update minimum cmake version to 3.22 (whole repository) 2025-08-19 14:44:32 +02:00
Marius Vikhammer
bf84ab652a change(test_utils): moved test_utils component to tools/test_apps/components/ 2025-07-21 14:05:50 +08:00
Sudeep Mohanty
c8f68c72a7 Merge branch 'feat/remove_global_cmake_vars' into 'master'
change(esptool_py): Make esptool_py component idempotent in the build

Closes IDF-13073

See merge request espressif/esp-idf!39589
2025-07-17 17:13:49 +02:00
Sudeep Mohanty
ef4d6462e2 refactor(esptool_py): Move flash target creation to project level and add utility functions
This commit refactors the esptool_py component to provide utility
functions for flash target management instead of creating the targets
directly. Flash target creation is now moved to the project level in
build.cmake file when idf_build_executable() runs.

The following changes were done in this commit:
- Added __esptool_py_setup_tools(), __esptool_py_setup_estool_py_args()
  and __ensure_esptool_py_setup() functions to centralize esptool_py
  setup.
- Added __esptool_py_setup_main_flash_target() which is called by
  idf_build_executable() to create the flash targets.
- Updated esptool_py_flash_target(), esptool_py_custom_target() to
  accept an optional FILENAME_PREFIX argument to enable creation of
  build artifacts based on custom names.
- Create placeholder flash targets early in the build process when
  idf_build_process() is called for components to add dependencies on
  these targets.
- Moved app-flash target creation from esptool_py/CMakeLists.txt to
  build.cmake.
- Added function description to esptool_py functions.
2025-07-10 11:26:28 +02:00
Sudeep Mohanty
30083e07be refactor(esptool_py): Re-evalute dependencies of esptool_py
This commit establishes the foundation for making the esptool_py
component idempotent.

The following changes are made in this commit:

- Removes unnecessary dependency of esp_wifi component on esptool_py.
- Add missing esptool_py dependencies to components which directly use
  esptool_py specific functions or variables but do not declare a public
  or private dependency.
2025-07-10 11:26:28 +02:00
Fu Hanxi
a5257dcc39 ci: apply idf-ci pytest plugin
Removed

- target markers. Now must use target as parametrization in esp-idf
- host test markers. Now will be automatically added with linux target and qemu marker
2025-07-09 10:33:28 +02:00
Fu Hanxi
fc4b2fbc28 Merge branch 'ci/disable-plugin-idf_ci' into 'master'
ci: disable idf-ci plugin

See merge request espressif/esp-idf!39600
2025-06-04 12:12:18 +02:00
Fu Hanxi
87a5aedb85 ci: disable idf-ci plugin
this plugin will be re-enabled with compatible code in !38755
2025-06-03 08:37:56 +02:00
radek.tandler
c23c21f3c0 refactor(nvs_flash): Improved Blob performance
The findItem method was improved to use a hash list in RAM when searching for BLOB data chunks

The findItem method was extended with a parameter that returns the position of an item on the page,
if it is found

The algorithm for matching existing variable-length data (such as strings and BLOBs) with
new values was enhanced by comparing the CRC32 of the data chunks before reading the data from flash
2025-06-02 16:01:40 +02:00