EasyManua.ls Logo

Espressif ESP32-S2 - Page 1460

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 4. API Guides
Allocating common symbols - This is a list of (some) global variables along with their sizes. Common
symbols have a particular meaning in ELF binary files, but ESP-IDF doesnt make much use of them.
Discarded input sections - These sections were read by the linker as part of an object file to be linked
into the final binary, but then nothing else referred to them so they were discarded from the final binary. For
ESP-IDF this list can be very long, as we compile each function and static variable to a unique section in order
to minimize the final binary size (specifically ESP-IDF uses compiler options -ffunction-sections
-fdata-sections and linker option --gc-sections). Items mentioned in this list do not contribute
to the final binary.
Memory Configuration, Linker script and memory map These two parts go together. Some
of the output comes directly from the linker command line and the Linker Script, both provided by the Build
System. The linker script is partially generated from the ESP-IDF project using the Linker Script Generation
feature.
As the output of the Linker script and memory map part of the map unfolds, you can see each
symbol (function or static variable) linked into the final binary along with its address (as a 16 digit hex number),
its length (also in hex), and the library and object file it was linked from (which can be used to determine the
component and the source file).
Following all of the output sections that take up space in the final .bin file, the memory map also includes
some sections in the ELF file that are only used for debugging (ELF sections .debug_*, etc.). These dont
contribute to the final binary size. Youll notice the address of these symbols is a very low number (starting
from 0x0000000000000000 and counting up).
Cross Reference Table. This table shows for each symbol (function or static variable), the list of
object file(s) that referred to it. If youre wondering why a particular thing is included in the binary, this will
help determine what included it.
Note: Unfortunately, the Cross Reference Table doesnt only include symbols that made it into the
final binary. It also includes symbols in discarded sections. Therefore, just because something is shown here
doesnt mean that it was included in the final binary - this needs to be checked separately.
Note: Linker map les are generated by the GNU binutils linker ld, not ESP-IDF. You can find additional
information online about the linker map file format. This quick summary is written from the perspective of ESP-IDF
build system in particular.
Reducing Overall Size The following configuration options will reduce the final binary size of almost any ESP-IDF
project:
Set CONFIG_COMPILER_OPTIMIZATION to Optimize for size (-Os). In some cases, Optimize for
performance (-O2)will also reduce the binary size compared to the default. Note that if your code contains
C or C++ Undefined Behaviour then increasing the compiler optimization level may expose bugs that otherwise
dont happen.
Reduce the compiled-in log output by lowering the app CONFIG_LOG_DEFAULT_LEVEL. If the CON-
FIG_LOG_MAXIMUM_LEVEL is changed from the default then this setting controls the binary size instead.
Reducing compiled-in logging reduces the number of strings in the binary, and also the code size of the calls
to logging functions.
Set the CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL to Silent. This avoids compiling in
a dedicated assertion string and source file name for each assert that may fail. Its still possible to find the
failed assert in the code by looking at the memory address where the assertion failed.
Besides the CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL, you can disable or silent the asser-
tion for HAL component separately by setting CONFIG_HAL_DEFAULT_ASSERTION_LEVEL.
Set CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT. This removes specic error messages for par-
ticular internal ESP-IDF error check macros. This may make it harder to debug some error conditions by
reading the log output.
Dont enable CONFIG_COMPILER_CXX_EXCEPTIONS, CONFIG_COMPILER_CXX_RTTI, or set the CON-
FIG_COMPILER_STACK_CHECK_MODE to Overall. All of these options are already disabled by default, but
they have a large impact on binary size.
Disabling CONFIG_ESP_ERR_TO_NAME_LOOKUP will remove the lookup table to translate user-friendly
Espressif Systems 1449
Submit Document Feedback
Release v4.4

Table of Contents