diff --git a/CMakeLists.txt b/CMakeLists.txt index e00a17e2e9..c6c4fb23ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,6 +159,10 @@ if(CONFIG_COMPILER_NO_MERGE_CONSTANTS) list(APPEND compile_options "-fno-merge-constants") endif() +if(CONFIG_COMPILER_ENABLE_TEXT_SECTION_LITERALS) + list(APPEND compile_options "-mtext-section-literals") +endif() + if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM) list(APPEND compile_options "-fstack-protector") elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG) diff --git a/Kconfig b/Kconfig index fec451c131..59957e2761 100644 --- a/Kconfig +++ b/Kconfig @@ -547,6 +547,20 @@ mainmenu "Espressif IoT Development Framework Configuration" distribution is more uniform across libraries. On downside, it may increase the binary size and hence should be used during development phase only. + config COMPILER_ENABLE_TEXT_SECTION_LITERALS + bool + depends on IDF_TOOLCHAIN_GCC + depends on IDF_TARGET_ARCH_XTENSA + default y if ESPTOOLPY_FAST_REFLASHING + help + Intersperse Xtensa literals within the text section to keep + them as close as possible to their references. This prevents + literals from being placed into a separate section in the + output file and prevents the linker from combining literal + pools from different object files. Enabling this is necessary + for fast reflashing to prevent mixing code from mutable and + immutable libraries. + config COMPILER_WARN_WRITE_STRINGS bool "Enable -Wwrite-strings warning flag" default "n" @@ -755,3 +769,4 @@ mainmenu "Espressif IoT Development Framework Configuration" - CONFIG_GDMA_ENABLE_WEIGHTED_ARBITRATION - CONFIG_I3C_MASTER_ENABLED - CONFIG_MBEDTLS_ESP_IDF_USE_PSA_CRYPTO + - CONFIG_ESPTOOLPY_FAST_REFLASHING diff --git a/components/esptool_py/Kconfig.projbuild b/components/esptool_py/Kconfig.projbuild index bbaa954ff1..8e6c99d908 100644 --- a/components/esptool_py/Kconfig.projbuild +++ b/components/esptool_py/Kconfig.projbuild @@ -202,4 +202,65 @@ menu "Serial flasher config" int default ESP_CONSOLE_UART_BAUDRATE if ESP_CONSOLE_UART default 115200 if !ESP_CONSOLE_UART + + menu "Fast Reflashing" + + config ESPTOOLPY_FAST_REFLASHING + bool "Enable fast reflashing (Experimental)" + depends on IDF_EXPERIMENTAL_FEATURES + select COMPILER_NO_MERGE_CONSTANTS if IDF_TOOLCHAIN_GCC + help + Enabling this option classifies component libraries into two + categories: mutable and immutable. Mutable libraries are + expected to change frequently during development, while + immutable libraries are considered stable. All project + component libraries are treated as mutable; all other libraries + are treated as immutable. + + In the generated linker script, input sections from immutable + libraries are placed before those from mutable libraries. This + layout helps localize changes in the output sections of the ELF + file, so that recompilation primarily affects a confined area + associated with the mutable libraries. + + This enables the generation of binary images with large + unmodified regions across recompilations, allowing to flash + only the parts that have changed. + + To support this, some compiler optimizations, such as constant + merging, are disabled, which helps minimize differences in the + binary image between builds. However, this may increase the + overall image size and flash usage. + + Additionally, this option inserts a padding, defined by the + ESPTOOLPY_FAST_REFLASHING_PADDING option, after the input + sections of mutable libraries. This allows further isolate + changes but also increases the size of the binary image and + flash consumption. + + choice ESPTOOLPY_FAST_REFLASHING_PADDING_SIZE + prompt "Padding size" + default ESPTOOLPY_FAST_REFLASHING_PADDING_4KB + depends on ESPTOOLPY_FAST_REFLASHING + help + Selects the amount of padding (in kilobytes) to add after input + sections of mutable libraries when fast reflashing is enabled. + + config ESPTOOLPY_FAST_REFLASHING_PADDING_2KB + bool "2 KB" + config ESPTOOLPY_FAST_REFLASHING_PADDING_4KB + bool "4 KB" + config ESPTOOLPY_FAST_REFLASHING_PADDING_8KB + bool "8 KB" + endchoice + + config ESPTOOLPY_FAST_REFLASHING_PADDING + int + depends on ESPTOOLPY_FAST_REFLASHING + default 2048 if ESPTOOLPY_FAST_REFLASHING_PADDING_2KB + default 4096 if ESPTOOLPY_FAST_REFLASHING_PADDING_4KB + default 8192 if ESPTOOLPY_FAST_REFLASHING_PADDING_8KB + + endmenu + endmenu