From bad4cd7072244a9bfb7911dbd810a7d9fef0a153 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Fri, 17 Mar 2023 09:39:43 +0530 Subject: [PATCH] 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. --- components/spi_flash/Kconfig | 1 + .../api-reference/peripherals/spi_flash/spi_flash_idf_vs_rom.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/components/spi_flash/Kconfig b/components/spi_flash/Kconfig index 0560ed937e..1383f8b79d 100644 --- a/components/spi_flash/Kconfig +++ b/components/spi_flash/Kconfig @@ -74,6 +74,7 @@ menu "SPI Flash driver" choice SPI_FLASH_DANGEROUS_WRITE bool "Writing to dangerous flash regions" + default SPI_FLASH_DANGEROUS_WRITE_ALLOWED if APP_BUILD_TYPE_RAM default SPI_FLASH_DANGEROUS_WRITE_ABORTS help SPI flash APIs can optionally abort or return a failure code diff --git a/docs/en/api-reference/peripherals/spi_flash/spi_flash_idf_vs_rom.rst b/docs/en/api-reference/peripherals/spi_flash/spi_flash_idf_vs_rom.rst index 43a3ca7878..a51d0315d6 100644 --- a/docs/en/api-reference/peripherals/spi_flash/spi_flash_idf_vs_rom.rst +++ b/docs/en/api-reference/peripherals/spi_flash/spi_flash_idf_vs_rom.rst @@ -19,6 +19,7 @@ Feature Supported by ESP-IDF but not in Chip-ROM - :ref:`CONFIG_SPI_FLASH_VERIFY_WRITE`, enabling this option helps you detect bad writing. - :ref:`CONFIG_SPI_FLASH_LOG_FAILED_WRITE`, enabling this option will print the bad writing. - :ref:`CONFIG_SPI_FLASH_WARN_SETTING_ZERO_TO_ONE`, enabling this option will check if you're writing zero to one. + - :ref:`CONFIG_SPI_FLASH_DANGEROUS_WRITE`, enabling this option will check for flash programming to certain protected regions like bootloader, partition table or application itself. :esp32h2 or esp32c6: - Flash MMAP driver isn't ready in Chip-ROM.