EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1465 background imageLoading...
Page #1465 background image
Chapter 4. API Guides
then no associated task is created. In those cases, the stack usage is zero and the stack size configuration for the task
is not relevant.
Reducing Heap Usage For functions that assist in analyzing heap usage at runtime, see Heap Memory Debugging.
Normally, optimizing heap usage consists of analyzing the usage and removing calls to malloc() that arent being
used, reducing the corresponding sizes, or freeing previously allocated buffers earlier.
There are some ESP-IDF configuration options that can reduce heap usage at runtime:
lwIP documentation has a section to configure Minimum RAM usage.
Wi-Fi Buer Usage describes options to either reduce numbers of staticbuffers or reduce the maximum
number of dynamicbuffers in use, in order to minimize memory usage at possible cost of performance.
Note that staticWi-Fi buffers are still allocated from heap when Wi-Fi is initialized and will be freed if
Wi-Fi is deinitialized.
mbedTLS TLS session memory usage can be minimized by enabling the ESP-IDF feature CON-
FIG_MBEDTLS_DYNAMIC_BUFFER.
Note: There are other configuration options that will increase heap usage at runtime if changed from the defaults.
These are not listed here, but the help text for the configuration item will mention if there is some memory impact.
Optimizing IRAM Usage The available DRAM at runtime (for heap usage) is also reduced by the static IRAM
usage. Therefore, one way to increase available DRAM is to reduce IRAM usage.
If the app allocates more static IRAM than is available then the app will fail to build and linker errors such as
section `.iram0.text' will not fit in region `iram0_0_seg', IRAM0 segment data
does not fit and region `iram0_0_seg' overflowed by 84 bytes will be seen. If this happens,
it is necessary to find ways to reduce static IRAM usage in order to link the application.
To analyze the IRAM usage in the firmware binary, use Measuring Static Sizes. If the firmware failed to link, steps to
analyze are shown at Showing Size When Linker Fails.
The following options will reduce IRAM usage of some ESP-IDF features:
Enable CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH. Provided these functions are not (incor-
rectly) used from ISRs, this option is safe to enable in all configurations.
Enable CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH. Enabling this option will place
snapshot-related functions, such as vTaskGetSnapshot or uxTaskGetSnapshotAll, in flash.
Disable Wi-Fi options CONFIG_ESP32_WIFI_IRAM_OPT and/or CONFIG_ESP32_WIFI_RX_IRAM_OPT.
Disabling these options will free available IRAM at the cost of Wi-Fi performance.
Disabling CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR prevents posting esp_event events from
IRAM-Safe Interrupt Handlers but will save some IRAM.
Disabling CONFIG_SPI_MASTER_ISR_IN_IRAM prevents spi_master interrupts from being serviced while
writing to flash, and may otherwise reduce spi_master performance, but will save some IRAM.
Setting CONFIG_HAL_DEFAULT_ASSERTION_LEVEL to disable assertion for HAL component will save
some IRAM especially for HAL code who calls HAL_ASSERT a lot and resides in IRAM.
Note: Moving frequently-called functions from IRAM to flash may increase their execution time.
Note: Other configuration options exist that will increase IRAM usage by moving some functionality into IRAM,
usually for performance, but the default option is not to do this. These are not listed here. The IRAM size impact of
enabling these options is usually noted in the configuration item help text.
Espressif Systems 1454
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish