183 Commits

Author SHA1 Message Date
Guillaume Souchere 5415465164 feat(esp_hw_support): Add esp_cpu.h support for linux builds 2026-03-17 07:49:36 +01:00
Antonio Almeida e09e5d658f docs(spi_flash): Fix redundant phrasing in esp_flash_get_size
Fixed redundant wording in esp_flash_get_size .
2026-02-28 10:43:56 +01:00
Xiao Xufeng 8dbf23630a refactor(spi_flash): reorganize header files and improve API encapsulation
This commit reorganizes SPI flash header files to better reflect their
visibility and intended usage:

1. Rename `esp_flash_port/` to `esp_flash_chips/`:
   - Better reflects that these headers are for chip driver implementations
   - All chip driver headers moved to `esp_flash_chips/` directory
   - Added README.md explaining semi-public nature of these headers

2. Move internal headers to `esp_private/`:
   - `esp_flash_internal.h` -> `esp_private/esp_flash_internal.h`
   - `memspi_host_driver.h` -> `esp_private/memspi_host_driver.h`

3. Move chip driver related headers to `esp_flash_chips/`:
   - `esp_private/esp_flash_types.h` -> `esp_flash_chips/esp_flash_types.h`
   - `spi_flash/spi_flash_defs.h` -> `esp_flash_chips/spi_flash_defs.h`
   - `spi_flash_override.h` -> `esp_flash_chips/spi_flash_override.h`
   - All `spi_flash_chip_*.h` headers moved to `esp_flash_chips/`

4. Code improvements:
   - Remove unused includes (e.g., `spi_flash_override.h` from `cache_utils.c`)
   - Use public API `esp_flash_get_size()` instead of direct member access
   - Add `esp_flash_is_quad_mode` to linker.lf for IRAM placement

5. Documentation updates:
   - Add README.md in `esp_flash_chips/` explaining semi-public headers
   - Update programming guide with warnings about internal headers
   - Update both English and Chinese documentation

6. Update all references across the codebase:
   - Update includes in `spi_flash` component
   - Update `bootloader_support`, `app_update`, `esp_tee`, `espcoredump`
   - Update example projects

Breaking changes:
- Headers moved to new locations require include path updates
- `custom_flash_driver` example temporarily disabled until external
  components are updated
2026-01-23 03:38:54 +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
wuzhenghui 353075ca30 change(esp_hw_support): reject sleep request if task stack in PSRAM 2025-12-19 10:27:28 +08:00
Xiao Xufeng 230ee88d99 feat(spi_flash): implement dynamic CPU frequency switching workaround for encrypted writes
This commit implements a workaround that allows ESP32-C5 to run at 240MHz CPU frequency
normally, while automatically reducing CPU frequency during encrypted flash writes to
ensure correct operation. The frequency limit is chip revision dependent:
- v1.2 and above: limited to 160MHz during encrypted writes
- v1.0 and below: limited to 80MHz during encrypted writes

Key implementation details:
- Frequency limiting is triggered automatically when esp_flash_write_encrypted() is called
- Uses start() flags (ESP_FLASH_START_FLAG_LIMIT_CPU_FREQ) to integrate with OS layer
- Works with both PM enabled and disabled configurations
- Frequency is automatically restored after encrypted write completes
- For ESP32-C5 with 120MHz flash, Flash clock and timing registers are adjusted when
  CPU frequency is reduced to 80MHz
- SPI1 timing registers are configured during frequency switching since encrypted writes
  use SPI1 and must work correctly at reduced CPU frequencies

Code improvements:
- Use SOC_MSPI_FREQ_AXI_CONSTRAINED capability macro instead of hardcoded chip checks
- Control workaround via Kconfig (CONFIG_PM_WORKAROUND_FREQ_LIMIT_ENABLED) instead of
  hardcoded macros
- Add comprehensive test cases covering various PM configurations and edge cases

This workaround enables ESP32-C5 applications to benefit from 240MHz CPU performance
while maintaining reliable encrypted flash write functionality.
2025-12-16 17:42:44 +08:00
He Binglin 7a4acd64c7 Merge branch 'feature/support_lightsleep_flash_dpd_mode' into 'master'
feat: Support set flash to deep power down mode in lightsleep

Closes PM-619 and IDF-7359

See merge request espressif/esp-idf!25578
2025-12-10 15:48:55 +08:00
hebinglin e29c2c9a36 feat(spi_flash): add flash deep power down support in spi flash 2025-12-09 17:19:01 +08:00
Adam Múdry cf95a64365 feat(bdl): Add support for spi_flash 2025-12-04 16:16:28 +01:00
armando 00022a379a change: remove deprecated items 2025-09-15 10:52:28 +08:00
C.S.M 34f9863115 fix(spi_flash): Fix spi flash qio/dio read failed on gpspi flash 2025-08-18 10:37:04 +08:00
C.S.M 332614165b refactor(spi_flash): Refactor gpspi flash for making it's clock accurate 2025-07-22 11:59:45 +08:00
C.S.M 15fa7843ae refactor(spi_flash): Add spi_flash driver list linked check 2025-04-10 15:36:11 +08:00
armando cbcee1625f refactor(flash): rename SOC_SPI_MEM_SUPPORT_OPI_MODE to SOC_SPI_MEM_SUPPORT_FLASH_OPI_MOD 2025-03-19 14:01:22 +08:00
wuzhenghui 7a4cc8ed35 fix(esp_hw_support): fix branch predictor access flash after cache disabled 2025-01-13 10:28:09 +08:00
C.S.M d448c4ed05 feat(spi_flash): Add 32M flash support on esp32c5 2024-12-25 16:06:43 +08:00
C.S.M c9d481c6d2 feat(spi_flash): support software resume after suspend in unicore 2024-11-22 13:48:45 +08:00
C.S.M ad6f491459 patch(spi_flash): cleanup XMC flash chip usage according to new information 2024-10-18 10:26:26 +08:00
Konstantin Kondrashov 0d4787fb3a feat(spi_flash): Adds esp_flash_set_dangerous_write_protection 2024-09-26 08:42:19 +03:00
C.S.M 374c89097f feat(spi_flash): Adjust flash clock to real 80M clock, and support 32bit address on eco1 2024-05-27 19:42:47 +08:00
Armando 10d3912c70 feat(xip_psram): support xip psram feature on esp32p4 2024-05-22 15:56:07 +08:00
Armando 13167d8479 change(flash): rename spi_timing_is_tuned to spi_flash_timing_is_tuned 2024-01-10 11:52:28 +08:00
Marius Vikhammer 52e3f09b32 refactor(spi): moved spi hw sharing func to hw support
Common spi functionality for sharing the SPI bus between modules is moved from esp_driver_spi to
a more fitting location in esp_hw_support (shared HW resource control).

This also allows us to decouple the spi_flash driver from esp_driver_spi, removing
esp_driver_spi and esp_ringbuf from G1 builds.
2023-11-20 12:07:54 +08:00
Xiao Xufeng 1f5fb3f921 spi_flash: fixed issue that enabling HPM-DC by default may cause app unable to restart 2023-10-24 10:38:08 +08:00
Adam Múdry ab1eb37fe8 feat(partition_table): Add read-only partition flag and functionality 2023-10-11 00:01:05 +02:00
Planck (Lu Zeyu) 255d499884 fix(ll): fix cpp compile error
Merges https://github.com/espressif/esp-idf/pull/12093

fix(ll): remove FLAG_ATTR macro

Such kind of operator overload will not work because C++ thinks such overload is ambiguous and it still prefer the built-in one which accepts and returns integer. Manually force type conversion seems to be unavoidable.
2023-09-14 14:48:12 +08:00
daiziyan 1037135761 docs: provided translation for storage.rst and system.rst and updated a typo for memory-types.rst 2023-07-27 16:24:29 +08:00
Cao Sen Miao 1ec55b7d1a spi_flash: Add GD25LQ255E flash support 2023-05-17 18:28:57 +08:00
Armando dbf3612d6d spi_flash: replace flash clock src change API with mspi timing API 2023-05-04 17:05:35 +08:00
gaoxu 542a61b6cb support SPI_FLASH_ENABLE_COUNTERS feature on esp_flash driver and rename the functions to esp_flash_xx 2023-04-06 11:40:40 +08:00
laokaiyao c9f780dc2e gpio: support runtime preserve 2023-03-17 11:59:49 +08:00
C.S.M b0b99a9a1b Merge branch 'feature/flash_support_h2' into 'master'
spi_flash: Allow clock frequency up to 64M on ESP32H2

See merge request espressif/esp-idf!22476
2023-03-10 19:13:03 +08:00
Cao Sen Miao bc655a6890 spi_flash: Allow clock frequency up to 64M, and make it default on ESP32H2 2023-03-10 11:39:53 +08:00
Armando d35b6dd852 spi_flash: support write verify feature on esp_flash_write_encrypted API 2023-03-09 14:55:13 +08:00
Armando 110853517a spi_flash: support write verify feature on esp_flash_write API 2023-03-09 14:55:13 +08:00
Cao Sen Miao 29e0258de2 spi_flash: init wrap in app stage 2023-02-14 18:20:53 +08:00
Cao Sen Miao 0d37436f36 spi_flash: Support flash wrap (burst read), flash driver side 2023-02-13 11:10:15 +08:00
Armando d233f3535d flash_mmap: migrate to use esp_mmap driver 2023-02-07 20:23:52 +08:00
Armando b46cfd15a2 mspi: move timing tuning to esp_hw_support 2023-01-06 14:41:20 +08:00
Michael (XIAO Xufeng) daa4af1b1f docs: split spi_flash api-reference documents to peripherals folder 2022-12-29 00:59:03 +08:00
Cao Sen Miao fa3a8fdd91 esp_flash: correct veriable 'size' description 2022-11-28 16:54:03 +08:00
C.S.M 54d9da987a Merge branch 'bugfix/flash_large_memory_size' into 'master'
spi_flash: Fix issue that cannot get accurate flash size when encounter large size memory

Closes IDFGH-8063

See merge request espressif/esp-idf!20738
2022-11-22 16:07:17 +08:00
Martin Vychodil c9c7573f71 Storage: Partition APIs moved to the new component 'esp_partition'
All the partition handling API functions and data-types were moved from the 'spi_flash' component to the new one named 'esp_partition'. See Storage 5.x migration guide for more details
2022-11-02 21:54:45 +01:00
Cao Sen Miao b4964279d4 spi_flash: Fix issue that cannot get accurate flash size when encounter large size memory,
Closes https://github.com/espressif/esp-idf/pull/9566
2022-10-31 11:05:36 +08:00
Cao Sen Miao 421e77d773 spi_flash: Add several flash chips HPM(120M) support 2022-09-13 17:06:43 +08:00
Shubham Kulkarni b6d69840e8 partition_table: Support registering custom subtypes 2022-08-03 05:18:37 +00:00
Cao Sen Miao ec6a56ed0c spi_flash: re-enable the HPM mode on several XMC chips 2022-07-22 09:54:56 +08:00
Jing Li 66395a5c00 system/sleep: further fix spi flash/ram current leakage 2022-07-21 19:14:26 +08:00
Cao Sen Miao a690a87829 spi_flash: Remove legacy spi_flash drivers 2022-07-01 11:01:34 +08:00
Cao Sen Miao 435bbb444c spi_flash: move cache stuff to private 2022-07-01 10:59:34 +08:00