Chapter 4. API Guides
4.19.5 DROM (data stored in Flash)
By default, constant data is placed by the linker into a region mapped to the MMU flash cache. This is the same as
the IROM (code executed from Flash) section, but is for read-only data not executable code.
The only constant data not placed into into this memory type by default are literal constants which are embedded by
the compiler into application code. These are placed as the surrounding function’s executable instructions.
The DRAM_ATTR attribute can be used to force constants from DROM into the DRAM (Data RAM) section (see
above).
4.19.6 RTC slow memory
Global and static variables used by code which runs from RTC memory must be placed into RTC slow memory. For
example deep sleep variables can be placed here instead of RTC fast memory, or code and variables accessed by the
ULP Coprocessor programming.
The attribute macro named RTC_NOINIT_ATTR can be used to place data into this type of memory. The values
placed into this section keep their value after waking from deep sleep.
Example:
RTC_NOINIT_ATTR uint32_t rtc_noinit_data;
4.19.7 DMA Capable Requirement
Most peripheral DMA controllers (e.g. SPI, sdmmc, etc.) have requirements that sending/receiving buffers should
be placed in DRAM and word-aligned. We suggest to place DMA buffers in static variables rather than in the stack.
Use macro DMA_ATTR to declare global/local static variables like:
DMA_ATTR uint8_t buffer[]="I want to send something";
void app_main()
{
// initialization code...
spi_transaction_t temp = {
.tx_buffer = buffer,
.length = 8 * sizeof(buffer),
};
spi_device_transmit(spi, &temp);
// other stuff
}
Or:
void app_main()
{
DMA_ATTR static uint8_t buffer[] = "I want to send something";
// initialization code...
spi_transaction_t temp = {
.tx_buffer = buffer,
.length = 8 * sizeof(buffer),
};
spi_device_transmit(spi, &temp);
// other stuff
}
It is also possible to allocate DMA-capable memory buffers dynamically by using the MALLOC_CAP_DMA capa-
bilities flag.
Espressif Systems 1423
Submit Document Feedback
Release v4.4