From 22d070e0aff16791bd78c1fb1b5aabe94c50349a Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Tue, 11 Jun 2019 10:45:26 +0200 Subject: [PATCH] spi_flash: Rename long Kconfig options --- components/spi_flash/Kconfig | 10 +++++----- components/spi_flash/flash_ops.c | 10 +++++----- components/spi_flash/include/esp_spi_flash.h | 4 ++-- components/spi_flash/sdkconfig.rename | 7 +++++++ components/spi_flash/test/test_out_of_bounds_write.c | 4 ++-- tools/ldgen/samples/sdkconfig | 6 +++--- tools/unit-test-app/sdkconfig.defaults | 2 +- 7 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 components/spi_flash/sdkconfig.rename diff --git a/components/spi_flash/Kconfig b/components/spi_flash/Kconfig index 969c7cc8a0..6ba4d5180d 100644 --- a/components/spi_flash/Kconfig +++ b/components/spi_flash/Kconfig @@ -52,9 +52,9 @@ menu "SPI Flash driver" This option is needed to write to flash on ESP32-D2WD, and any configuration where external SPI flash is connected to non-default pins. - choice SPI_FLASH_WRITING_DANGEROUS_REGIONS + choice SPI_FLASH_DANGEROUS_WRITE bool "Writing to dangerous flash regions" - default SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS + default SPI_FLASH_DANGEROUS_WRITE_ABORTS help SPI flash APIs can optionally abort or return a failure code if erasing or writing addresses that fall at the beginning @@ -69,11 +69,11 @@ menu "SPI Flash driver" ROM functions. These functions should not be called directly from IDF applications. - config SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS + config SPI_FLASH_DANGEROUS_WRITE_ABORTS bool "Aborts" - config SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS + config SPI_FLASH_DANGEROUS_WRITE_FAILS bool "Fails" - config SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED + config SPI_FLASH_DANGEROUS_WRITE_ALLOWED bool "Allowed" endchoice diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index 8aae45f0e2..7b3f5b1f8a 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -77,7 +77,7 @@ const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_default_ops = { .end = spi_flash_enable_interrupts_caches_and_other_cpu, .op_lock = spi_flash_op_lock, .op_unlock = spi_flash_op_unlock, -#if !CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED +#if !CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED .is_safe_write_address = is_safe_write_address #endif }; @@ -87,14 +87,14 @@ const DRAM_ATTR spi_flash_guard_funcs_t g_flash_guard_no_os_ops = { .end = spi_flash_enable_interrupts_caches_no_os, .op_lock = 0, .op_unlock = 0, -#if !CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED +#if !CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED .is_safe_write_address = 0 #endif }; static const spi_flash_guard_funcs_t *s_flash_guard_ops; -#ifdef CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS +#ifdef CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS #define UNSAFE_WRITE_ADDRESS abort() #else #define UNSAFE_WRITE_ADDRESS return false @@ -104,7 +104,7 @@ static const spi_flash_guard_funcs_t *s_flash_guard_ops; /* CHECK_WRITE_ADDRESS macro to fail writes which land in the bootloader, partition table, or running application region. */ -#if CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED +#if CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED #define CHECK_WRITE_ADDRESS(ADDR, SIZE) #else /* FAILS or ABORTS */ #define CHECK_WRITE_ADDRESS(ADDR, SIZE) do { \ @@ -112,7 +112,7 @@ static const spi_flash_guard_funcs_t *s_flash_guard_ops; return ESP_ERR_INVALID_ARG; \ } \ } while(0) -#endif // CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED +#endif // CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED static __attribute__((unused)) bool is_safe_write_address(size_t addr, size_t size) { diff --git a/components/spi_flash/include/esp_spi_flash.h b/components/spi_flash/include/esp_spi_flash.h index 254e408959..74c96fd36c 100644 --- a/components/spi_flash/include/esp_spi_flash.h +++ b/components/spi_flash/include/esp_spi_flash.h @@ -336,7 +336,7 @@ typedef bool (*spi_flash_is_safe_write_address_t)(size_t addr, size_t size); * - 'op_unlock' unlocks access to flash API internal data. * These two functions are recursive and can be used around the outside of multiple calls to * 'start' & 'end', in order to create atomic multi-part flash operations. - * 3) When CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is disabled, flash writing/erasing + * 3) When CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is disabled, flash writing/erasing * API checks for addresses provided by user to avoid corruption of critical flash regions * (bootloader, partition table, running application etc.). * @@ -354,7 +354,7 @@ typedef struct { spi_flash_guard_end_func_t end; /**< critical section end function. */ spi_flash_op_lock_func_t op_lock; /**< flash access API lock function.*/ spi_flash_op_unlock_func_t op_unlock; /**< flash access API unlock function.*/ -#if !CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED +#if !CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED spi_flash_is_safe_write_address_t is_safe_write_address; /**< checks flash write addresses.*/ #endif } spi_flash_guard_funcs_t; diff --git a/components/spi_flash/sdkconfig.rename b/components/spi_flash/sdkconfig.rename new file mode 100644 index 0000000000..6f9d592269 --- /dev/null +++ b/components/spi_flash/sdkconfig.rename @@ -0,0 +1,7 @@ +# sdkconfig replacement configurations for deprecated options formatted as +# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION + +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS CONFIG_SPI_FLASH_DANGEROUS_WRITE +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED diff --git a/components/spi_flash/test/test_out_of_bounds_write.c b/components/spi_flash/test/test_out_of_bounds_write.c index 3c9b017476..9b411b0365 100644 --- a/components/spi_flash/test/test_out_of_bounds_write.c +++ b/components/spi_flash/test/test_out_of_bounds_write.c @@ -4,11 +4,11 @@ #include "esp_spi_flash.h" #include "esp_ota_ops.h" -#if CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS || CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS +#if CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS || CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS static const char *data = "blah blah blah"; -#if CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS +#if CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS #define TEST_TAGS "[spi_flash]" #else // ABORTS #define TEST_TAGS "[spi_flash][ignore]" diff --git a/tools/ldgen/samples/sdkconfig b/tools/ldgen/samples/sdkconfig index fcbe556260..8fbfd61586 100644 --- a/tools/ldgen/samples/sdkconfig +++ b/tools/ldgen/samples/sdkconfig @@ -494,9 +494,9 @@ CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 CONFIG_SPI_FLASH_VERIFY_WRITE= CONFIG_SPI_FLASH_ENABLE_COUNTERS= CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS= -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED= +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS= +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED= # # SPIFFS Configuration diff --git a/tools/unit-test-app/sdkconfig.defaults b/tools/unit-test-app/sdkconfig.defaults index fca065641e..ca30ad526d 100644 --- a/tools/unit-test-app/sdkconfig.defaults +++ b/tools/unit-test-app/sdkconfig.defaults @@ -19,7 +19,7 @@ CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_SPI_FLASH_ENABLE_COUNTERS=y CONFIG_ESP32_ULP_COPROC_ENABLED=y CONFIG_ESP_TASK_WDT=n -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS=y CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=7 CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y CONFIG_COMPILER_STACK_CHECK=y