Commit Graph

72 Commits

Author SHA1 Message Date
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
armando 755ee49b72 feat(mspi): supported psram & flash 120MHz timing tuning 2025-10-28 09:52:36 +08:00
C.S.M c81cf3bdf6 refactor(spi_flash): Remove spi_flash rom driver patch config option 2025-10-22 10:37:19 +08:00
C.S.M f022b67486 feat(spi_flash): Support flash suspend on esp32p4 resivion 3 2025-09-28 16:25:28 +08:00
C.S.M b194636859 feat(spi_flash): Add spi flash suspend support on esp32c5, esp32c61 2025-06-06 15:03:41 +08:00
C.S.M 0f1dbcc6a5 fix(spi_flash): Make GD chip to be linked as default, also optimization the log information 2025-05-22 17:35:09 +08:00
armando 9b845f9f8b fix(flash): mutex between flash rom impl and flash opi 2025-03-20 15:32:21 +08:00
C.S.M 9aba44a2d9 test(spi_flash): Flash suspend test evolution 2025-03-11 16:21:07 +08:00
C.S.M 6c3d67b234 fix(spi_flash): Add suspend check on esp32c6 and esp32h2 for some reason 2025-03-11 11:11:39 +08:00
C.S.M add27dfbd3 fix(spi_flash): Fix flash encryption write verify,
Closes https://github.com/espressif/esp-idf/issues/15380
2025-02-28 15:57:24 +08:00
C.S.M b66e140fbc refactor(spi_flash): optimize flash functions to save iram memory 2025-02-26 18:28:49 +08:00
C.S.M 5e4fd8ee52 refactor(bod): Move brownout handling file from esp_system to esp_hw_support 2025-01-08 14:41:37 +08:00
C.S.M 81426057b5 feat(spi_flash): Add config for adding auto check status after suspend to improve performance 2024-12-18 14:55:25 +08:00
Armando 1eef2e8c19 feat(mspi): supported flash 120MHz SDR timing tuning on ESP32P4 2024-11-28 14:53:19 +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
C.S.M 9e864ffe26 feat(spi_flash): Add suspend support on esp32c5, esp32c61 2024-09-10 10:36:27 +08:00
Cao Sen Miao dcff5220a7 feat(spi_flash): Support configurable tSUS in flash suspend 2023-11-06 18:04:43 +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
Cao Sen Miao 6cea72b76b fix(ota): Fixed OTA fail on octal flash with 32MB memory,
Closes https://github.com/espressif/esp-idf/issues/11903
2023-10-13 12:01:26 +08:00
Krzysztof 290ca75ae0 [docs] Update API Reference of SPI Flash for AR2023-003 2023-08-27 18:31:31 +08:00
Cao Sen Miao ed96dadd06 spi_flash: 2nd stage for supporting flash suspend. (1). Support more esp chips (2). Improve real-time performance (3). Making timing more stable (4) Add documents 2023-05-11 20:10:30 +08:00
wanlei b519eed230 spi_flash: fix config SPI_FLASH_SHARE_SPI1_BUS dependency 2023-04-21 18:57:06 +08:00
Cao Sen Miao c7053641bc spi_flash: 32M bits address flash map, (for customer use only) 2023-04-14 11:37:09 +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
Armando 739b3f03fb kconfig: make 120 MSPI DDR as experimental feature 2023-04-03 10:30:50 +08:00
Mahavir Jain bad4cd7072 spi_flash: RAM loadable ELF should have dangerous writes option allowed
For RAM loadable ELF case, there is no application or the bootloader on
the flash. And hence the check for getting current running OTA partition
or looking up partition table fails during dangerous writes option.

We are disabling the dangerous writes option for RAM loadable ELF case
and allowing writes to entire flash memory.
2023-03-20 11:10:29 +05:30
Armando 110853517a spi_flash: support write verify feature on esp_flash_write API 2023-03-09 14:55:13 +08:00
Cao Sen Miao 0f8f13d21d spi_flash: only link flash vendor which is officially supported to save IRAM 2023-02-09 10:28:54 +08:00
wuzhenghui 44df5b31af feature: add ram loadable app support 2023-02-01 17:57:22 +08:00
wuzhenghui ff8dd1e1a8 esp32c6: add spi_flash support 2022-09-26 20:32:13 +08:00
Cao Sen Miao ec6a56ed0c spi_flash: re-enable the HPM mode on several XMC chips 2022-07-22 09:54:56 +08:00
Cao Sen Miao a690a87829 spi_flash: Remove legacy spi_flash drivers 2022-07-01 11:01:34 +08:00
Cao Sen Miao 6a2d3509dc spi_flash: Making XMC flash works more stable when brownout detected 2022-06-02 10:38:55 +08:00
wuzhenghui d8de64bff8 Kconfig: add depends 2022-05-06 15:26:43 +08:00
jiangguangming a9f8b20431 spi_flash: enable ESP32C2 SPI_FLASH_ROM_IMPL 2022-05-05 17:41:11 +08:00
Cao Sen Miao 5bf739aef3 spi_flash: Add hint for explaining erase yield 2022-01-17 09:52:54 +08:00
Cao Sen Miao 56edc81b5d spi_flash: add support for th 1M flash 2021-12-13 11:47:48 +08:00
Cao Sen Miao 6c0aebe279 esp_flash: add opi flash support in esp_flash chip driver, for MXIC 2021-09-07 14:44:40 +08:00
Michael (XIAO Xufeng) 26585b4b4b esp_flash: support override default chip driver list 2021-04-26 16:05:42 +08:00
Cao Sen Miao c54ea54d98 spi_flash: make suspend off by default and add more information for using suspend 2021-03-26 13:57:14 +08:00
Michael (XIAO Xufeng) a0573f5b9f spi_flash: make the auto_suspend default y on C3 2021-02-04 14:11:04 +08:00
Mahavir Jain e712a91488 spi_flash: add config option to enable encrypted partition read/write
This feature can be disabled to save some IRAM (approx 1KB) for cases
where flash encryption feature is not required.
2021-01-28 12:19:21 +00:00
Cao Sen Miao f3e79ca166 spi_flash(c3): add boya chip support for suspend feature 2021-01-25 11:14:06 +08:00
Cao Sen Miao 9905da46e0 spi_flash: Add auto suspend mode on esp32c3 2021-01-25 11:14:02 +08:00
KonstantinKondrashov afef16c2e9 spi_flash: Support suspend/resume mode for operations
- Adds arbitration between the erase and write in suspend mode
     (If the flash memory is suspended then only a read operation can be performed.)
- espcoredump: Dump does not use suspend feature, just resume before continue.
- spi_flash: Add release_cpu() to do suspend/release_cpu/resume
2021-01-25 11:13:38 +08:00
Ivan Grokhotkov 7f3b16a99d freertos: always enable static allocation
to use it for newlib locks
2020-12-29 16:18:04 +01:00
Angus Gratton d4c9a45675 spi_flash: Add ESP32-C3 support
Based on internal commit 3ef01301fff
2020-12-17 15:34:13 +11:00
Michael (XIAO Xufeng) 3bacf35310 esp_flash: support high capacity flash chips (32-bit address) 2020-10-29 18:20:11 +08:00
Cao Sen Miao b9f6efd99a esp_flash: change timeout threshold and can close timeout 2020-10-12 10:43:25 +08:00