Chapter 4. API Guides
[mapping:my_component]
archive: libmy_component.a
entries:
if PERFORMANCE_LEVEL = 1:
my_src1 (noflash)
elif PERFORMANCE_LEVEL = 2:
my_src1 (noflash)
my_src2 (noflash)
elif PERFORMANCE_LEVEL = 3:
my_src1 (noflash)
my_src2 (noflash)
my_src3 (noflash)
else:
* (rtc)
Nesting condition-checking is also possible. The following is equivalent to the snippet above:
[mapping:my_component]
archive: libmy_component.a
entries:
if PERFORMANCE_LEVEL <= 3 && PERFORMANCE_LEVEL > 0:
if PERFORMANCE_LEVEL >= 1:
object1 (noflash)
if PERFORMANCE_LEVEL >= 2:
object2 (noflash)
if PERFORMANCE_LEVEL >= 3:
object2 (noflash)
else:
* (rtc)
The ‘default’placements
Up until this point, the term ‘default placements’has been mentioned as fallback placements when the placement
rules rtc and noflash are not specified. It is important to note that the tokens noflash or rtc are not merely
keywords, but are actually entities called fragments, specifically schemes.
In the same manner as rtc and noflash are schemes, there exists a default scheme which defines what the de-
fault placement rules should be. As the name suggests, it is where code and data are usually placed, i.e. code/constants
is placed in flash, variables placed in RAM, etc. More on the default scheme here.
Note: For an example of an ESP-IDF component using the linker script generation mechanism, see freer-
tos/CMakeLists.txt. freertos uses this to place its object files to the instruction RAM for performance reasons.
This marks the end of the quick start guide. The following text discusses the internals of the mechanism in a little bit
more detail. The following sections should be helpful in creating custom placements or modifying default behavior.
4.18.3 Linker Script Generation Internals
Linking is the last step in the process of turning C/C++ source files into an executable. It is performed by the
toolchain’s linker, and accepts linker scripts which specify code/data placements, among other things. With the
linker script generation mechanism, this process is no different, except that the linker script passed to the linker is
dynamically generated from: (1) the collected linker fragment files and (2) linker script template.
Note: The tool that implements the linker script generation mechanism lives under tools/ldgen.
Espressif Systems 1414
Submit Document Feedback
Release v4.4