mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-28 19:34:59 +00:00
a034ef8713
Introduce ESPTOOLPY_FAST_REFLASHING configuration option. It instructs
ldgen to group entity mappings for libraries deemed mutable (prone to
change) separately from those considered immutable (unlikely to change).
Organizing mutable and immutable libraries separately in the linker
script allows the linker to form larger contiguous blocks of data for
immutable libraries in the application's output sections. These blocks
are likely to stay mostly unchanged between application recompilations,
enabling them to be skipped during reflashing.
Separating mutable and immutable libraries in the linker script to
minimize changes in the output sections is insufficient. Padding is
added after the input sections of mutable libraries in the default data
and text output sections. This creates a buffer for the mutable
libraries, allowing additional changes to be made without altering the
layout of the binary image.
Additionally two optimizations currently in use can still mix data from
these libraries, leading to significant changes even within the grouped
immutable libraries.
1. constant merging
Linker will try to merge input sections that have the MERGE and
STRING flags from different libraries (object files) to perform
optimizations like tail merging. For example, adding a string
literal in a mutable library will also change the addresses of
string literals from immutable libraries in such a merged section,
causing changes in the generated code when those literals are
referenced.
Disabled with COMPILER_DISABLE_MERGE_CONSTANTS(-fno-merge-constants)
2. literal pools on Xtensa
As optimization, the linker may merge literal pools from different
libraries (object files) to improve the generated code size. This
has the same effect as constant merging, and changes in mutable
libraries may cause changes in the generated code for immutable
libraries. To get larger unchanged continuous blocks in the text
output sections for immutable libraries, we need to ensure that the
Xtensa literal pools remain close to their references and are not
merged.
Disabled with CONFIG_COMPILER_ENABLE_TEXT_SECTION_LITERALS(-mtext-section-literals)
When ESPTOOLPY_FAST_REFLASHING is enabled, these two optimizations are
disabled to achieve larger unchaged continuous blocks for the grouped
immutable libraries, even though disabling these optimizations results
in slightly larger code.
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
267 lines
11 KiB
Plaintext
267 lines
11 KiB
Plaintext
menu "Serial flasher config"
|
|
depends on !APP_BUILD_TYPE_PURE_RAM_APP
|
|
|
|
config ESPTOOLPY_NO_STUB
|
|
bool "Disable download stub"
|
|
default y if IDF_ENV_FPGA || IDF_ENV_BRINGUP
|
|
default n
|
|
|
|
help
|
|
The flasher tool sends a precompiled download stub first by default. That stub allows things
|
|
like compressed downloads and more. Usually you should not need to disable that feature
|
|
|
|
config ESPTOOLPY_OCT_FLASH
|
|
depends on SOC_SPI_MEM_SUPPORT_FLASH_OPI_MODE
|
|
bool "Enable Octal Flash"
|
|
default n
|
|
|
|
config ESPTOOLPY_FLASH_MODE_AUTO_DETECT
|
|
depends on SOC_SPI_MEM_SUPPORT_FLASH_OPI_MODE
|
|
bool "Choose flash mode automatically (please read help)"
|
|
default y
|
|
help
|
|
This config option helps decide whether flash is Quad or Octal, but please note some limitations:
|
|
|
|
1. If the flash chip is an Octal one, even if one of "QIO", "QOUT", "DIO", "DOUT" options is
|
|
selected in `ESPTOOLPY_FLASHMODE`, our code will automatically change the
|
|
mode to "OPI" and the sample mode will be STR.
|
|
2. If the flash chip is a Quad one, even if "OPI" is selected in `ESPTOOLPY_FLASHMODE`, our code will
|
|
automatically change the mode to "DIO".
|
|
3. This option is mainly to improve the out-of-box experience of developers. It doesn't guarantee
|
|
the feature-complete. Some code still rely on `ESPTOOLPY_OCT_FLASH`. Please do not rely on this option
|
|
when you are pretty sure that you are using Octal flash.
|
|
In this case, please enable `ESPTOOLPY_OCT_FLASH` option, then you can choose `DTR` sample mode
|
|
in `ESPTOOLPY_FLASH_SAMPLE_MODE`. Otherwise, only `STR` mode is available.
|
|
4. Enabling this feature reduces available internal RAM size (around 900 bytes).
|
|
If your IRAM space is insufficient and you're aware of your flash type,
|
|
disable this option and select corresponding flash type options.
|
|
|
|
choice ESPTOOLPY_FLASHMODE
|
|
prompt "Flash SPI mode"
|
|
default ESPTOOLPY_FLASHMODE_DIO
|
|
default ESPTOOLPY_FLASHMODE_OPI if ESPTOOLPY_OCT_FLASH
|
|
help
|
|
Mode the flash chip is flashed in, as well as the default mode for the
|
|
binary to run in.
|
|
|
|
config ESPTOOLPY_FLASHMODE_QIO
|
|
depends on !ESPTOOLPY_OCT_FLASH
|
|
bool "QIO"
|
|
config ESPTOOLPY_FLASHMODE_QOUT
|
|
depends on !ESPTOOLPY_OCT_FLASH
|
|
bool "QOUT"
|
|
config ESPTOOLPY_FLASHMODE_DIO
|
|
depends on !ESPTOOLPY_OCT_FLASH
|
|
bool "DIO"
|
|
config ESPTOOLPY_FLASHMODE_DOUT
|
|
depends on !ESPTOOLPY_OCT_FLASH
|
|
bool "DOUT"
|
|
config ESPTOOLPY_FLASHMODE_OPI
|
|
depends on ESPTOOLPY_OCT_FLASH
|
|
bool "OPI"
|
|
endchoice
|
|
|
|
choice ESPTOOLPY_FLASH_SAMPLE_MODE
|
|
prompt "Flash Sampling Mode"
|
|
default ESPTOOLPY_FLASH_SAMPLE_MODE_DTR if ESPTOOLPY_OCT_FLASH
|
|
default ESPTOOLPY_FLASH_SAMPLE_MODE_STR if !ESPTOOLPY_OCT_FLASH
|
|
|
|
config ESPTOOLPY_FLASH_SAMPLE_MODE_STR
|
|
bool "STR Mode"
|
|
config ESPTOOLPY_FLASH_SAMPLE_MODE_DTR
|
|
depends on ESPTOOLPY_OCT_FLASH
|
|
bool "DTR Mode"
|
|
endchoice
|
|
|
|
# Note: we use esptool to flash bootloader in
|
|
# dio mode for QIO/QOUT, bootloader then upgrades
|
|
# itself to quad mode during initialisation
|
|
config ESPTOOLPY_FLASHMODE
|
|
string
|
|
default "dio" if ESPTOOLPY_FLASHMODE_QIO
|
|
default "dio" if ESPTOOLPY_FLASHMODE_QOUT
|
|
default "dio" if ESPTOOLPY_FLASHMODE_DIO
|
|
default "dout" if ESPTOOLPY_FLASHMODE_DOUT
|
|
# The 1st and 2nd bootloader doesn't support opi mode,
|
|
# using fastrd instead. For now the ESPTOOL doesn't support
|
|
# fasted (see ESPTOOL-274), using dout instead. In ROM the flash mode
|
|
# information get from efuse, so don't care this dout choice.
|
|
default "dout" if ESPTOOLPY_FLASHMODE_OPI
|
|
|
|
orsource "../spi_flash/$IDF_TARGET/Kconfig.flash_freq"
|
|
|
|
config ESPTOOLPY_FLASHFREQ
|
|
string
|
|
# On some of the ESP chips, max boot frequency would be equal to (or even lower than) 80m.
|
|
# We currently define this to `80m`.
|
|
default '80m' if ESPTOOLPY_FLASHFREQ_120M
|
|
default '80m' if ESPTOOLPY_FLASHFREQ_80M
|
|
default '60m' if ESPTOOLPY_FLASHFREQ_60M
|
|
default '48m' if ESPTOOLPY_FLASHFREQ_64M # For 0xf in esptool
|
|
default '48m' if ESPTOOLPY_FLASHFREQ_48M
|
|
default '24m' if ESPTOOLPY_FLASHFREQ_32M # For 0x0 in esptool
|
|
default '30m' if ESPTOOLPY_FLASHFREQ_30M
|
|
default '24m' if ESPTOOLPY_FLASHFREQ_24M
|
|
default '40m' if ESPTOOLPY_FLASHFREQ_40M
|
|
default '26m' if ESPTOOLPY_FLASHFREQ_26M
|
|
default '20m' if ESPTOOLPY_FLASHFREQ_20M
|
|
default '12m' if ESPTOOLPY_FLASHFREQ_16M # For 0x2 in esptool
|
|
default '20m' # if no clock can match in bin headers, go with minimal.
|
|
|
|
|
|
choice ESPTOOLPY_FLASHSIZE
|
|
prompt "Flash size"
|
|
default ESPTOOLPY_FLASHSIZE_2MB
|
|
help
|
|
SPI flash size, in megabytes
|
|
|
|
config ESPTOOLPY_FLASHSIZE_1MB
|
|
bool "1 MB"
|
|
config ESPTOOLPY_FLASHSIZE_2MB
|
|
bool "2 MB"
|
|
config ESPTOOLPY_FLASHSIZE_4MB
|
|
bool "4 MB"
|
|
config ESPTOOLPY_FLASHSIZE_8MB
|
|
bool "8 MB"
|
|
config ESPTOOLPY_FLASHSIZE_16MB
|
|
bool "16 MB"
|
|
config ESPTOOLPY_FLASHSIZE_32MB
|
|
bool "32 MB"
|
|
config ESPTOOLPY_FLASHSIZE_64MB
|
|
bool "64 MB"
|
|
config ESPTOOLPY_FLASHSIZE_128MB
|
|
bool "128 MB"
|
|
endchoice
|
|
|
|
config ESPTOOLPY_FLASHSIZE
|
|
string
|
|
default "1MB" if ESPTOOLPY_FLASHSIZE_1MB
|
|
default "2MB" if ESPTOOLPY_FLASHSIZE_2MB
|
|
default "4MB" if ESPTOOLPY_FLASHSIZE_4MB
|
|
default "8MB" if ESPTOOLPY_FLASHSIZE_8MB
|
|
default "16MB" if ESPTOOLPY_FLASHSIZE_16MB
|
|
default "32MB" if ESPTOOLPY_FLASHSIZE_32MB
|
|
default "64MB" if ESPTOOLPY_FLASHSIZE_64MB
|
|
default "128MB" if ESPTOOLPY_FLASHSIZE_128MB
|
|
|
|
config ESPTOOLPY_HEADER_FLASHSIZE_UPDATE
|
|
bool "Detect flash size when flashing bootloader"
|
|
default n
|
|
help
|
|
If this option is set, flashing the project will automatically detect
|
|
the flash size of the target chip and update the bootloader image
|
|
before it is flashed.
|
|
|
|
Enabling this option turns off the image protection against corruption
|
|
by a SHA256 digest. Updating the bootloader image before flashing would
|
|
invalidate the digest.
|
|
|
|
choice ESPTOOLPY_BEFORE
|
|
prompt "Before flashing"
|
|
default ESPTOOLPY_BEFORE_RESET
|
|
help
|
|
Configure whether esptool should reset the ESP32 before flashing.
|
|
|
|
Automatic resetting depends on the RTS & DTR signals being
|
|
wired from the serial port to the ESP32. Most USB development
|
|
boards do this internally.
|
|
|
|
config ESPTOOLPY_BEFORE_RESET
|
|
bool "Reset to bootloader"
|
|
config ESPTOOLPY_BEFORE_NORESET
|
|
bool "No reset"
|
|
endchoice
|
|
|
|
config ESPTOOLPY_BEFORE
|
|
string
|
|
default "default-reset" if ESPTOOLPY_BEFORE_RESET
|
|
default "no-reset" if ESPTOOLPY_BEFORE_NORESET
|
|
|
|
choice ESPTOOLPY_AFTER
|
|
prompt "After flashing"
|
|
default ESPTOOLPY_AFTER_RESET
|
|
help
|
|
Configure whether esptool should reset the ESP32 after flashing.
|
|
|
|
Automatic resetting depends on the RTS & DTR signals being
|
|
wired from the serial port to the ESP32. Most USB development
|
|
boards do this internally.
|
|
|
|
config ESPTOOLPY_AFTER_RESET
|
|
bool "Reset after flashing"
|
|
config ESPTOOLPY_AFTER_NORESET
|
|
bool "Stay in bootloader"
|
|
endchoice
|
|
|
|
config ESPTOOLPY_AFTER
|
|
string
|
|
default "hard-reset" if ESPTOOLPY_AFTER_RESET
|
|
default "no-reset" if ESPTOOLPY_AFTER_NORESET
|
|
|
|
config ESPTOOLPY_MONITOR_BAUD
|
|
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
|