Irom (Code Executed From Flash); Rtc Fast Memory - Espressif ESP32-S2 Programming Manual

Table of Contents

Advertisement

Chapter 4. API Guides
How to place code in IRAM
Some code is automatically placed into the IRAM region using the linker script.
If some specific application code needs to be placed into IRAM, it can be done by using the
feature and adding a linker script fragment file to your component that targets entire source files or functions with the
noflash placement. See the
Alternatively, it's possible to specify IRAM placement in the source code using the IRAM_ATTR macro:
#include "esp_attr.h"
void IRAM_ATTR
gpio_isr_handler(void*
{
// ...
}
There are some possible issues with placement in IRAM, that may cause problems with IRAM-safe interrupt handlers:
• Strings or constants inside an IRAM_ATTR function may not be placed in RAM automatically. It' s possible to
use DRAM_ATTR attributes to mark these, or using the linker script method will cause these to be automatically
placed correctly.
void
IRAM_ATTR
{
const static
const static
}
Note that knowing which data should be marked with DRAM_ATTR can be hard, the compiler will sometimes
recognize that a variable or expression is constant (even if it is not marked const) and optimize it into flash,
unless it is marked with DRAM_ATTR.
• GCC optimizations that automatically generate jump tables or switch/case lookup tables place these tables in
flash. IDF by default builds all files with -fno-jump-tables -fno-tree-switch-conversion flags to avoid this.
Jump table optimizations can be re-enabled for individual source files that don't need to be placed in
IRAM. For instructions on how to add the -fjump-tables -ftree-switch-conversion options when compil-
ing individual source files, see

4.19.3 IROM (code executed from Flash)

If a function is not explicitly placed into
mechanism by which Flash MMU is used to allow code execution from flash is described in ESP32-S2 Technical
Reference Manual > Memory Management and Protection Units (MMU, MPU) [PDF]. As IRAM is limited, most of
an application's binary code must be placed into IROM instead.
During
Application Startup
the app' s instruction code region to the instruction space. Flash accessed via the MMU is cached using some internal
SRAM and accessing cached flash data is as fast as accessing other types of internal memory.

4.19.4 RTC fast memory

The same region of RTC fast memory can be accessed as both instruction and data memory. Code which has to run
after wake-up from deep sleep mode has to be placed into RTC memory. Please check detailed description in
sleep
documentation.
Remaining
RTC
fast
FIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP
with
DRAM (Data
RAM), but is slightly slower to access.
Espressif Systems
Linker Script Generation
arg)
gpio_isr_handler(void*
DRAM_ATTR
uint8_t
INDEX_DATA[]
char
*MSG
=
DRAM_STR("I am a string stored in
Controlling Component Compilation
IRAM (Instruction RAM)
Flow, the bootloader (which runs from IRAM) configures the MMU flash cache to map
memory
is
added
Submit Document Feedback
docs for more information.
arg)
=
{ 45, 33, 12,
or RTC memory, it is placed into flash. The
to
the
heap
is disabled. This memory can be used interchangeably
1422
Linker Script Generation
0
};
RAM");
unless
the
option
Release v4.4
deep
CON-

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF