73 Commits

Author SHA1 Message Date
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
Frantisek Hrbata d4d778182f fix(esp_partition/cmake): remove unused PRIV_INCLUDE_DIRS
Currently, the bootloader version of the `esp_partition` component sets
`PRIV_INCLUDE_DIRS` using the `private_include_dirs` variable. However,
this variable is not properly initialized, which causes issues in
cmakev2. In cmakev2, components are evaluated recursively, and a
component may be evaluated in the context of another component, so
components must initialize all variables before using them.

Moreover, there are effectively no `PRIV_INCLUDE_DIRS` to set when the
component is evaluated for the bootloader. Therefore, remove
`PRIV_INCLUDE_DIRS` entirely for bootloader and test builds.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-03-27 19:18:11 +08:00
Ashish Sharma f93575a622 feat(secure_boot): adds api to verify data partition integrity
Closes https://github.com/espressif/esp-idf/issues/17482
2026-03-04 10:22:33 +08:00
Tomáš Rohlínek 4575ac1f5e feat(storage): Minimize dependencies for test cases 2026-02-18 13:43:27 +01:00
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
Tomáš Rohlínek 49b1871545 fix(storage/partition): Update sizes in blockdev geometry in read-only mode for compatibility 2026-02-05 15:35:05 +01:00
Chen Jichang b8c527a87c refactor(flash_enc): move esp_flash_encryption_enabled() to efuse component 2026-02-05 11:42:08 +08:00
Michael (XIAO Xufeng) 5984b29af5 Merge branch 'refactor/spi_flash_private' into 'master'
refactor(spi_flash): reorganize header files, improve encapsulation and simplify ROM implementation

See merge request espressif/esp-idf!44347
2026-01-28 17:39:51 +08:00
igor.udot 4c26ab876b ci: update build-test-rules to use common_components 2026-01-23 10:14:09 +08:00
Xiao Xufeng 758cf6e1a3 refactor(spi_flash): move internal types to private headers and refactor initialization
This commit refactors the SPI flash component to improve encapsulation and
modularity by moving internal types and functions to private headers, and
reorganizing initialization code.

Key changes:

1. Move PSRAM frequency constraint macro from soc_caps.h to mspi_ll.h
   - Rename SOC_SPI_MEM_PSRAM_FREQ_AXI_CONSTRAINED to
     MSPI_TIMING_LL_PSRAM_FREQ_AXI_CONSTRAINED
   - Move macro definition to chip-specific mspi_ll.h files (C5, C61, H4, P4, S31)
   - Update usage in clk_utils.c and esp_flash_spi_init.c
   - Remove old macro from all soc_caps.h files

2. Move internal types to private headers
   - Move esp_flash_t structure to esp_private/esp_flash_types.h
   - Move esp_flash_os_functions_t to esp_private/spi_flash_os.h
   - Update all internal files to include private headers
   - Keep forward declarations in public esp_flash.h

3. Move chip driver header to internal directory
   - Move spi_flash_chip_driver.h to esp_flash_port/spi_flash_chip_driver.h
   - Update all references to use new path
   - Add esp_private/esp_flash_types.h include to the moved header

4. Refactor initialization functions
   - Move init_flash from esp_system/startup_funcs.c to
     spi_flash/esp_flash_spi_init.c
   - Create new init_pm_flash_freq_limit function in startup_funcs.c
     to call esp_pm_flash_freq_limit_init() conditionally
   - Update system_init_fn.txt with new function locations

5. Improve API encapsulation
   - Replace direct access to esp_flash_t->size in
     esp_partition_register_external() with esp_flash_get_size() API
   - Move esp_flash_is_quad_mode from inline function to regular function
     in esp_flash_api.c

6. Update component dependencies
   - Add esp_driver_gpio to spi_flash component PRIV_REQUIRES
   - Remove unused includes and clean up header dependencies

These changes improve code organization by clearly separating public APIs
from internal implementation details, making the codebase more maintainable
and reducing the risk of breaking changes to internal structures.
2026-01-23 03:38:54 +08:00
morris 291554cd09 refactor(global): remove completed todos in the codebase 2025-12-15 22:40:15 +08:00
sonika.rathi 6216b017f0 feat(vfs): add 'fatfs' host test to include 'vfs' support 2025-11-05 09:49:21 +01:00
Martin Vychodil 3ce5725282 fix(esp_partition): read-only and encrypted partition support 2025-10-09 09:06:54 +02:00
Martin Vychodil 5c8a10e61e fix(esp_partition): fixes related to BDL update 2025-10-09 09:06:40 +02:00
Martin Vychodil 4493b39d18 feat(storage): Added Block Device Layer support for esp_partition component 2025-10-07 14:55:36 +08:00
sonika.rathi 5b65634b49 feat(esp_partition): add error-returning variants for partition find APIs
Add esp_partition_find_err() and esp_partition_find_first_err() to provide
error reporting while maintaining backward compatibility.

Closes https://github.com/espressif/esp-idf/issues/9281
2025-09-29 15:00:41 +02:00
Konstantin Kondrashov b7da740f12 Merge branch 'feature/log_v2_optimization' into 'master'
feat(log): Optimize idf components for binary logging

Closes IDF-12775

See merge request espressif/esp-idf!40289
2025-09-19 14:45:43 +08:00
sonika.rathi 2fa2010aa4 feat(esp_partition): add support for partition tables larger than 4MB with linux target 2025-09-16 22:23:06 +08:00
Konstantin Kondrashov dcf486359e feat(log): Optimize log tag init for bin logging 2025-09-15 15:59:52 +03:00
Marek Fiala 9d35d63651 feat(cmake): Update minimum cmake version to 3.22 (whole repository) 2025-08-19 14:44:32 +02:00
Laukik Hase 41bf07e6ce refactor(esp_tee): Remove the deprecated TEE secure storage partition subtype 2025-05-04 18:03:30 +05:30
Laukik Hase c9f7bcd452 feat(esp_tee): Support the nvs_flash for the ESP-TEE build 2025-05-04 18:03:28 +05:30
igor.udot daf2d31008 test: format all test scripts 2025-03-05 12:08:48 +08:00
Mahavir Jain 3821d6cb97 fix(esp_tee): TEE otadata partition default encrypted for flash-enc case 2025-03-03 15:50:47 +08:00
harshal.patil 4c38499303 fix(esp_partition): Support reading unencrypted partitions by the bootloader
- When flash encryption is enable to support reading a partition that is not
marked as "encrypted", the `esp_partition_read()` API of bootloader build
should be redirected to the `bootloader_flash_read()` API.
2025-01-29 18:51:28 +05:30
harshal.patil 2ee22f968a fix(nvs_flash): Allow matching with partition when label provided is NULL
- When esp_parition_find_first() is called with the partition label provided
as NULL by the bootloader, allowing matching to the first partition that matches
partition_type and partition_subtype as done in the app variant.
2025-01-29 18:51:28 +05:30
Laukik Hase 2dee5791a6 feat(esp_tee): Support for ESP-TEE - esptool_py, esp_rom & other components 2024-12-02 11:27:58 +05:30
Radek Tandler 8255ba29a6 Merge branch 'feature/storage_nvs_bootloader' into 'master'
feat(storage/nvs): NVS bootloader support

See merge request espressif/esp-idf!31753
2024-11-15 00:12:18 +08:00
radek.tandler c445ec134b feat(nvs_flash): Implemented basic nvs_flash support for bootloader 2024-11-14 11:56:45 +01:00
Konstantin Kondrashov 52f14f344d feat(partition_table): Support recovery bootloader subtype 2024-11-12 17:22:53 +08:00
Konstantin Kondrashov 97d150d69a feat(app_update): OTA update bootloader, partition_table and other partitions
Passive app partition can be used as the staging partition where a new image is loaded.
Then copy it to the final partition.

Closes: https://github.com/espressif/esp-idf/issues/14195
Closes: https://github.com/espressif/esp-idf/issues/13824
2024-11-07 13:48:51 +02:00
Konstantin Kondrashov d5f37b526d feat(partitions): Adds new partition types and subtypes for bootloader and partition_table 2024-10-01 14:22:22 +03:00
Konstantin Kondrashov 02d61c1c5a feat(esp_partition): Adds new esp_partition APIs 2024-09-26 08:42:12 +03:00
Sonika Rathi d5da858cd9 refactor: remove dependency on spi_flash include for sector size 2024-09-26 13:01:24 +08:00
Alexey Lapshin 4c87af6359 fix(build): fix calloc warnings 2024-09-08 13:53:52 +07:00
Konstantin Kondrashov 0bdf675992 fix(linux): Fix warnings for Linux target when COMPILER_STATIC_ANALYZER=y 2024-07-31 11:23:54 +03:00
sonika.rathi a81f5768c6 fix(esp_partition): fix data type overflow sanity check 2024-07-08 22:19:19 +08:00
Tomáš Rohlínek f753434640 fix(storage/esp_partition): add option to control erase check during write for linux target 2024-05-28 10:05:58 +02:00
Adam Múdry 050db26419 Merge branch 'fix/coverity_use_after_free_partition.c' into 'master'
fix(partition): Simplify macro loop in esp_partition_unload_all, should fix Coverity problem

Closes IDF-9837

See merge request espressif/esp-idf!30853
2024-05-23 23:08:11 +08:00
Adam Múdry c2ac9bad62 fix(partition): Simplify macro loop in esp_partition_unload_all 2024-05-22 10:54:14 +02:00
Martin Vychodil b24a6af0b7 Merge branch 'refactor/partition_private_includes' into 'master'
refactor(esp_partition): Made private includes private on Linux

See merge request espressif/esp-idf!29747
2024-05-21 04:02:14 +08:00
Jakob Hasse 69c04f4adf refactor(esp_partition): Made private includes private on Linux 2024-05-13 16:02:19 +02:00
harshal.patil 3eb6487bb5 fix(bootloader_support): Make esp_flash_encrypt.h independent of spi_flash_mmap.h header 2024-05-13 16:54:45 +05:30
Ivan Grokhotkov 10cc15b150 fix(storage): applied spelling fixes by codespell pre-commit hook 2024-03-28 13:00:54 +01:00
Jakob Hasse 4d629be602 refactor(linux): Unified libbsd handling
* Users can now use libbsd string.h and sys/cdefs.h functionality
  (e.g., strlcpy, containerof) on Linux by just including
  string.h or sys/cdefs.h. In other words, the includes are the same
  on the Linux target as well as on chips targets (ESP32, etc.).
* libbsd linking is done by the linux component (belongs to common
  components) now instead of handling it separately in each component
2024-03-08 12:26:54 +08:00
sonika.rathi f7e4b9a132 fix(storage): cleanup storage examples/test_apps sdkconfigs 2024-02-12 10:57:46 +01:00
Tomáš Rohlínek 092f5aff29 feat(storage): Update build test rules for storage related components 2024-01-02 13:10:59 +01:00
Adam Múdry 0cc38fb901 refactor(esp_partition): Expose function for unloading partitions
Closes https://github.com/espressif/esp-idf/issues/12625
2023-11-22 11:13:32 +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