Chapter 4. API Guides
• a component named my_component that is archived as library libmy_component.a during build
• three source files archived under the library, my_src1.c, my_src2.c and my_src3.c which are com-
piled as my_src1.o, my_src2.o and my_src3.o, respectively
• under my_src1.o, the function my_function1 is defined; under my_src2.o, the function
my_function2 is defined
• there is bool-type config PERFORMANCE_MODE (y/n) and int type config PERFORMANCE_LEVEL (with
range 0-3) in my_component's Kconfig
Creating and Specifying a Linker Fragment File
Before anything else, a linker fragment file needs to be created. A linker fragment file is simply a text file with a .lf
extension upon which the desired placements will be written. After creating the file, it is then necessary to present it
to the build system. The instructions for the build systems supported by ESP-IDF are as follows:
Make
In the component's component.mk file, set the variable COMPONENT_ADD_LDFRAGMENTS to the
path of the created linker fragment file. The path can either be an absolute path or a relative path from the component
directory.
COMPONENT_ADD_LDFRAGMENTS
CMake
In the component's CMakeLists.txt file,
idf_component_register call.
relative path from the component directory to the created linker fragment file.
# file paths relative to CMakeLists.txt
idf_component_register(...
another_linker_fragment_file.lf"
→
Specifying placements
It is possible to specify placements at the following levels of granularity:
• object file (.obj or .o files)
• symbol (function/variable)
• archive (.a files)
Placing object files
Suppose the entirety of my_src1.o is performance-critical, so it is desirable to place it in
RAM. On the other hand, the entirety of my_src2.o contains symbols needed coming out of deep sleep, so it needs
to be put under RTC memory. In the the linker fragment file, we can write:
[mapping:my_component]
archive: libmy_component.a
entries:
my_src1 (noflash)
my_src2 (rtc)
RTC fast memory/RTC slow memory
→
Espressif Systems
- src/
-
my_src1.c
-
my_src2.c
-
my_src3.c
-
my_linker_fragment_file.lf
+=
my_linker_fragment_file.lf
The value of LDFRAGMENTS can either be an absolute path or a
LDFRAGMENTS "path/to/linker_fragment_file.lf" "path/to/
...
)
# places all my_src1 code/read-only data under IRAM/DRAM
# places all my_src2 code/ data and read-only data
1412
Submit Document Feedback
(continued from previous page)
specify argument LDFRAGMENTS in the
under␣
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers