Chapter 4. API Guides
Allow .bss segment placed in external memory
Enable this option by checking CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY. This configuration
setting is independent of the other three.
If enabled, a region of the address space starting from 0x3F500000 will be used to store zero-initialized data (BSS
segment) from the lwIP, net80211, libpp, and bluedroid ESP-IDF libraries.
Additional data can be moved from the internal BSS segment to external RAM by applying the macro
EXT_RAM_ATTR to any static declaration (which is not initialized to a non-zero value).
It is also possible to place the BSS section of a component or a library to external RAM using linker fragment scheme
extram_bss.
This option reduces the internal static memory used by the BSS segment.
Remaining external RAM can also be added to the capability heap allocator using the method shown above.
4.11.4 Restrictions
External RAM use has the following restrictions:
• When flash cache is disabled (for example, if the flash is being written to), the external RAM also becomes
inaccessible; any reads from or writes to it will lead to an illegal cache access exception. This is also the reason
why ESP-IDF does not by default allocate any task stacks in external RAM (see below).
• External RAM cannot be used as a place to store DMA transaction descriptors or as a buffer for a DMA transfer
to read from or write into. Any buffers that will be used in combination with DMA must be allocated using
heap_caps_malloc(size, MALLOC_CAP_DMA) and can be freed using a standard free() call.
• External RAM uses the same cache region as the external flash. This means that frequently accessed variables
in external RAM can be read and modified almost as quickly as in internal ram. However, when accessing
large chunks of data (>32 KB), the cache can be insufficient, and speeds will fall back to the access speed of
the external RAM. Moreover, accessing large chunks of data can “push out”cached flash, possibly making
the execution of code slower afterwards.
• In general, external RAM cannot be used as task stack memory. Due to this, xTaskCreate() and similar
functions will always allocate internal memory for stack and task TCBs, and functions such as xTaskCre-
ateStatic() will check if the buffers passed are internal.
4.11.5 Failure to initialize
By default, failure to initialize external RAM will cause the ESP-IDF startup to abort. This can be
disabled by enabling the config item CONFIG_SPIRAM_IGNORE_NOTFOUND.
If CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is enabled, the option to ignore failure
is not available as the linker will have assigned symbols to external memory addresses at link time.
4.11.6 Encryption
It is possible to enable automatic encryption for data stored in external RAM. When this is enabled any data read and
written through the cache will automatically be encrypted/decrypted by the external memory encryption hardware.
This feature is enabled whenever flash encryption is enabled. For more information on how to enable and how it
works see Flash Encryption.
4.12 Fatal Errors
Espressif Systems 1334
Submit Document Feedback
Release v4.4