Commit Graph

653 Commits

Author SHA1 Message Date
morris
0315e2fb2e feat(build): support aligned embedded binary data
Allow callers to align embedded binary start symbols for DMA-capable
assets.
2026-07-21 10:40:18 +08:00
Renz Christian Bagaporo
faca8f56a3 Merge branch 'feat/cmakev2_ulp_full_subproject' into 'master'
feat(ulp): initial support for building ULP projects as full subprojects under CMake v2

See merge request espressif/esp-idf!50134
2026-07-16 21:00:32 +08:00
Frantisek Hrbata
aaca1e20ea feat(cmakev2): preprocess linker scripts with component includes
Resolve #include lines in linker script templates against the linked
component graph: idf_build_library appends every linked component's
INCLUDE_DIRS to the C preprocessor invocation for each .in linker
script, so a template can include any component header (e.g. a ULP
memory-layout template including soc/soc.h) without the owning
component having to know about it.

Also:
- Always pass -I<config_dir> so templates can include sdkconfig.h.
- Add a FLAGS option to target_linker_script for explicit preprocessor
  flags (e.g. -D__ASSEMBLER__ or ld-snippet include dirs); when given,
  FLAGS replaces the parent-dir==target include heuristic for that
  script.
- Add a MEMORY option to target_linker_script that emits the marked
  linker script as -T before all others, so section-placement scripts
  in one component can reference MEMORY regions and REGION_ALIASes
  declared by a memory-layout script in another component.
- Make C-preprocessor comment keeping (-C) part of the default flag set
  rather than hardcoded, so FLAGS can drop it. linker_script_preprocessor
  no longer forces -C; both the cmakev1 and cmakev2 preprocessors add it
  to their default CFLAGS (output unchanged for existing scripts). A ULP
  template that includes soc/soc.h omits -C so ld does not choke on the
  header's // comments.
- Store per-script metadata (generated output, flags) in MD5-keyed
  component properties instead of parallel lists.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-15 09:14:35 +09:00
Ivan Grokhotkov (bot)
d20a986999 feat(build): add options to enable link-time optimization (LTO)
Link-time optimization (LTO) lets the compiler inline and optimize across
translation units. ESP-IDF relies heavily on linker-script placement rules
that match object files by name, which LTO does not preserve, so LTO cannot
be enabled for the whole framework. This change adds two opt-in options that
side-step that conflict:

- CONFIG_COMPILER_LTO_LINKTIME tells the linker to perform LTO on any object
  files that carry LTO information (compiled with -flto). On its own this is
  safe: users can add -flto to specific components (e.g. their own libraries)
  to shrink them, without affecting components that use linker fragments.

- CONFIG_COMPILER_LTO_COMPILETIME automatically compiles most
  components with -flto. A component is excluded when it has its own linker
  fragments, when it opts out via the NO_LTO component property, or when its
  object code is placed by *another* component's linker fragment (matched by
  archive name). The last case is handled by tools/cmake/lto.cmake, which
  scans linker fragments for explicit "archive: libNAME.a" placement and
  excludes those components. Without it, functions that must run from IRAM
  while the flash cache is disabled (e.g. the spi_flash / GDMA HAL routines,
  placed in IRAM by spi_flash/esp_driver_dma fragments) would be moved to
  flash by LTO and the device would panic with a cache error at run time.

Both options are disabled for the bootloader and ESP-TEE builds, which depend
on object-file-name based placement. LTO is also gated off for Clang
(needs LLD, IDF-8286) and host builds.

LTO works together with CONFIG_APP_REPRODUCIBLE_BUILD, but needs extra
flags: LTO defers code generation and most debug-info emission from compile
time to link time, where the reproducible-build path remapping (applied to
compile_options only) does not take effect. When both options are enabled,
three extra flags keep the .elf, .bin and .map byte-identical across build
directories (verified on esp32 / GCC 16.1):

- the -f*-prefix-map options are passed to the linker as well, so the LTO
  code generator remaps DW_AT_comp_dir (otherwise the build dir leaks into
  .debug_str, and cascades into esp_app_desc_t.app_elf_sha256 in the .bin);
- -save-temps makes lto-wrapper use stable LTRANS object names in the build
  dir instead of random $TMPDIR paths that leak into the .map;
- -frandom-seed=1 makes LTO GIMPLE bytecode objects byte-identical (a
  shared seed was verified not to collide, including for C++ file-local
  static variables and anonymous namespaces promoted by LTO).

The gcc-ar / gcc-ranlib wrappers are selected in the GCC toolchain file so
that the LTO plugin is loaded when creating and indexing static archives;
plain ar/ranlib do not record LTO symbols in the archive index.

Note: LTO, like other inlining, can also increase binary size. Enable it
together with CONFIG_COMPILER_OPTIMIZATION_SIZE to get a code-size benefit.

Related: IDF-71, IDF-8286

Closes https://github.com/espressif/esp-idf/issues/18741

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 18:59:46 +02:00
Sudeep Mohanty
5671695359 fix(gdbinit): build elf path from EXECUTABLE_NAME, not the target name
The EXECUTABLE build property holds a CMake target name, not a filesystem
path. Under Build system v1 the target happens to be created as
"<project>.elf", so concatenating BUILD_DIR with EXECUTABLE produced a valid
elf path by coincidence. Under Build system v2 the target is just "<project>"
and the elf is written as "<project>.elf" via CMake's executable suffix, so
the same concatenation pointed gdb at a non-existent file.

Construct the path explicitly from EXECUTABLE_NAME plus the .elf suffix so
the gdbinit consumer no longer depends on the producer naming its target
after the output file.
2026-07-01 13:17:25 +02:00
Jan Beran
fa61d8c902 Merge branch 'fix/remove-menuconfig-curses' into 'master'
Cleanup after dropping curses from menuconfig

See merge request espressif/esp-idf!48246
2026-06-17 18:24:53 +08:00
Jan Beran
dd742179ee fix: cleanup after dropping curses from menuconfig
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 16:56:46 +02:00
Sudeep Mohanty
a91cac9495 feat(cmake): add IDF_BUILD_V2 shim for transparent cmakev2 delegation
When IDF_BUILD_V2 evaluates to a CMake-truthy value, project.cmake
delegates to Build system v2 (cmakev2). The shim wraps project(),
forwards the app-declared COMPONENTS list via __SHIM_COMPONENTS, and
publishes __V1_COMPAT_SHIM so Build system v2 internals can gate Build
system v1 compatibility behavior. Existing app CMakeLists.txt files
build unchanged.

Co-authored-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-06-15 14:58:45 +02:00
Jiang Guang Ming
0c835d2141 fix(dfu): retry dfu-util flash on macOS detach failure
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 15:40:34 +08:00
JiangGuangMing
dd9eb63e9d feat: support esp32s31 dfu feature 2026-06-05 15:59:04 +08:00
Jakub Kocka
2e5d930e6b fix(tools): Windows builds when paths contain spaces (prefix_map, ldgen, CI)
- Harden prefix_map.cmake for paths with spaces on Windows

- ldgen: fragments-list-file, list normalization, CMake integration (tools/cmake + cmakev2)

- CI exclude list for check_tools; test_spaces bundle tweak

Made-with: Cursor
2026-06-04 14:45:05 +08:00
Jan Beran
9522af1d8f feat: introduce esp-idf-configdep as a build optimization
The esp-idf-configdep utility works as a compiler wrapper. It lets the
compiler compile the app and checks whether -MF option was used to
generate dependency files. If yes, it checks for sdkconfig.h dependency
in those files.

Target file depending on sdkconfig.h is then scanned for all CONFIG_*
occurrences and the dependency file is altered so that the given target
file is marked as "dirty" only if the config options it actually uses
are changed.

This ensures that after a configuration update, only affected files are
rebuilt, reducing incremental build times.

The compiler launcher mechanism is changed from RULE_LAUNCH_COMPILE
(Makefile-only) to CMAKE_*_COMPILER_LAUNCHER (generator-agnostic),
enabling launcher chaining (configdep -> ccache -> compiler).

Made-with: Cursor
2026-06-02 01:26:10 +08:00
Guillaume Souchere
33e774397c Merge branch 'feat/error-code-registration' into 'master'
feat(esp_common): implement composable error code registration via link-time arrays

Closes IDF-15105 and IDF-15486

See merge request espressif/esp-idf!46125
2026-06-01 09:40:37 +02:00
Jan Beran
c974f9420b feat(menuconfig): optimize menuconfig speed
When esp-idf-kconfig >= 3.9.0 is installed, we can use the optimized
menuconfig target without the need to preprocess the sdkconfig file by
kconfgen (removing deprecated options - menuconfig - readding deprecated
options).

Also removed unused {menuconfig_depends} from the new target.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 14:57:48 +08:00
Guillaume Souchere
d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00
Ivan Grokhotkov
6589ba9bbb change(version): Update version to v6.2-dev
Start of v6.2 development.
2026-05-25 14:16:08 +02:00
Chen Ji Chang
ee9e481ae4 Merge branch 'feat/support_lcd_gdb_buffer_display' into 'master'
feat(lcd): provide a gdb extension to dump buffer

Closes IDF-15296

See merge request espressif/esp-idf!47902
2026-05-19 19:37:37 +08:00
Chen Jichang
eb429c95d4 feat(idf_drivers_gdb): provide a gdb extension to dump buffer 2026-05-15 19:34:30 +08:00
Alexey Gerenkov
edb75262a1 Merge branch 'feature/update-esp-clang-to-esp-21.1.3_20260304' into 'master'
feat(tools): update esp-clang version to esp-21.1.3_20260408

Closes IDF-14965, LLVM-501, and LLVM-531

See merge request espressif/esp-idf!46361
2026-05-13 22:54:10 +08:00
Frantisek Hrbata
df6ee7dc26 fix(build): prevent sdkconfig corruption during multiple component manager runs
The build system currently suffers from a bug where custom configuration
settings are lost when the component manager is invoked multiple times.
During an initial reconfigure or set-target command, the component
manager may return no managed components. Because the build system lacks
the Kconfig definitions for these components at this stage, it
automatically prunes any related configuration symbols—specifically
those defined in managed component Kconfig files—from the sdkconfig
file. By the time the component manager finishes downloading the
dependencies in a subsequent run, these original settings have already
been overwritten and discarded because they were previously unrecognized
by the build system.

To resolve this, the generation of the final sdkconfig should be
deferred until all component manager resolution cycles are complete. We
need to ensure that the build system does not treat missing Kconfig
definitions as invalid until the full dependency graph is loaded. A
potential fix involves using a temporary configuration file for
intermediate component manager passes to prevent the main sdkconfig from
being prematurely scrubbed of valid user settings that belong to
yet-to-be-resolved components.

Edit:
Added cleanup of sdkconfig.cm file and comments

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Edited by: Daniel Paul <daniel.paul@espressif.com>
2026-05-11 18:55:47 +08:00
Daniel Paul
ead48b7dbd feat: Component Manager interface version 5 2026-05-11 18:55:47 +08:00
Alexey Gerenkov
97e6873e34 feat(tools): update esp-clang version to esp-21.1.3_20260304 2026-05-07 17:42:32 +03:00
Samuel Obuch
508bb73d76 change(cmake): use lpcore openocd configs with CONFIG_ULP_COPROC_TYPE_LP_CORE 2026-05-07 11:59:48 +02:00
Marek Fiala
bb2d197129 fix: Try to enclose args and paths in quotes 2026-04-27 12:41:53 +02:00
Roland Dobai
13b56cec79 fix(cmake): quote variable references in conditional expressions
Closes https://github.com/espressif/esp-idf/issues/18445
2026-04-16 13:41:48 +02:00
Radim Karniš
c62515671d change(build): Rename Fast reflashing configuration to Minimize binary changes, make non-experimental 2026-04-02 10:53:32 +02:00
Daniel Paul
914d32c101 Merge branch 'feat/move-cjson-to-root-dep' into 'master'
feat: support moving idf components to component registry

Closes PACMAN-1102

See merge request espressif/esp-idf!39704
2026-03-25 18:10:42 +08:00
Roland Dobai
f46452d3ab feat(cmake): Create a merged hints database in the build directory 2026-03-23 09:24:45 +01:00
Fu Hanxi
c360d8be98 feat: support moving idf components to component registry
and mark it as root dependency
2026-03-17 21:02:49 +08:00
Alexey Lapshin
338cc50125 fix(build): fix passing CMAKE_<LANG>_FLAGS from ExternalProject_Add 2026-03-13 17:23:11 +08:00
Frantisek Hrbata
a4c014f96e fix(cmake): Fall back to version from components when git describe fails
When version.txt does not exist and git describe fails (e.g. in
release archives or environments without git), IDF_VER was set to
the raw git_describe output which resolves to "-128-NOTFOUND",
causing esp_get_idf_version() to return a garbled string.

Add a fallback that constructs the version string from the
IDF_VERSION_MAJOR, IDF_VERSION_MINOR and IDF_VERSION_PATCH
variables when git describe is not available.

Closes https://github.com/espressif/esp-idf/issues/18240

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-02-20 15:50:55 +08:00
Frantisek Hrbata
795904a41c fix(build): ensure the main component exists when MINIMAL_BUILD is enabled
The minimal build property is simply a shorthand for `set(COMPONENTS
main)`. The issue is that there is currently no check to verify whether
the `main` component actually exists or is known to the build system.
If the `main` component is not present, print an error message along
with suggestions on how to fix this inconsistency.

Closes https://github.com/espressif/esp-idf/issues/18219

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-02-10 03:36:48 +08:00
david zuhn
d25272d0de fix(build): Correct the usage example for idf_build_replace_option_from_property 2026-01-27 12:42:53 -06:00
Ferdinand Bachmann
d3afb79c98 fix(cmake): Fix "IMPORTED_LOCATION not set for imported target" errors
esp-idf uses imported targets as dummy targets that are never linked.
Previous CMake versions would ignore these and not error on unset
IMPORTED_LOCATION if they are never actually linked. CMake 4.2 and newer
errors during codemodel-v2 api queries when imported targets are missing
IMPORTED_LOCATION, so set a dummy location that would error when
actually linked, which fixes the error during api queries.

Closes https://github.com/espressif/esp-idf/pull/18103
2026-01-14 21:49:07 +08:00
Frantisek Hrbata
0f011477aa fix(cmake): disable MINIMAL_BUILD build property if COMPONENTS is defined
The MINIMAL_BUILD build property and the COMPONENTS variable are both
used to determine the initial component list for the build.

Currently, if the COMPONENTS variable is set, the MINIMAL_BUILD logic
is ignored during component selection, but the MINIMAL_BUILD build
property remains set. This leads to an inconsistent state where
menuconfig displays information indicating MINIMAL_BUILD is active,
even though it was ignored in favor of the COMPONENTS variable.

Fix this by setting the MINIMAL_BUILD property to OFF if the
COMPONENTS variable is used.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-01-13 21:58:55 +08:00
Marek Fiala
9d6c0ee7ce feat(tools): Clean up esp-idf-size new generation 2025-12-18 03:43:04 +08:00
Roland Dobai
7e25d7220a Merge branch 'feat/add_components_source_to_project_description' into 'master'
Feat: Add source of the component into project_description.json

Closes IDF-14123

See merge request espressif/esp-idf!39829
2025-12-04 06:37:47 +01:00
Daniel Paul
039206921d feat: Add source of the component into project_description.json 2025-12-03 19:58:47 +08:00
Alexey Lapshin
31810ae993 feat(esp_libc): make picolibc default libc 2025-12-03 13:31:42 +07:00
Jan Beran
132f191874 feat(core-ext): Add refresh-config command
This command will allow users to resolve mismatches in default values
between sdkconfig and Kconfig according to a policy specified:

* sdkconfig: Using default values from sdkconfig (backward compatible)
* interactive: User can choose the source for every affected config
  option separatedly
* kconfig: Using default values from Kconfig
2025-11-25 20:31:08 +08:00
Jan Beran
bf9b9a0259 change(kconfig): add support for configuration report 2025-11-18 20:42:38 +08:00
Roland Dobai
a295be6658 Merge branch 'feat/ldgen_fast_reflashing' into 'master'
feat(ldgen): initial support for fast reflashing

Closes IDF-14213

See merge request espressif/esp-idf!42780
2025-11-18 10:28:49 +01:00
C.S.M
a90c93541c feat(esp32s31): Introduce new target esp32s31 2025-11-17 14:48:55 +08:00
Alexey Lapshin
0c1d917f78 feat(build): propagate compiler flags from files to toolchain.cmake
This change improves build consistency across external projects integrated
through CMake by ensuring that compiler flags defined in configuration files
are passed correctly to the toolchain. It covers the majority of use cases,
as external projects are typically also CMake-based. For projects that use
a custom build system, users will still need to specify the required flags
manually.
2025-11-14 21:04:54 +07:00
Frantisek Hrbata
1eceeaace2 feat(build): provide ldgen with a list of mutable libraries
The build system keeps track of each component source. Currently
there are four types of sources:

1. "project_components" - project components
2. "project_extra_components" - components from EXTRA_COMPONENT_DIRS
3. "project_managed_components" - custom project dependencies managed by the IDF Component Manager
4. "idf_components" - ESP-IDF built-in components, typically under /components

This can be used to identify the component libraries that are likely to
change during application development and pass them to ldgen as mutable
libraries. Add all components with "project_components" as their source
as mutable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
7116d9dc01 feat(toolchain): more remove_duplicated_flags function to separate file
Currently, the toolchain CMake files use the remove_duplicated_flags
function from utilities.cmake. The cmakev2 implementation also includes
this function for backward compatibility. Move the
remove_duplicated_flags function to a separate file,
deduplicate_flags.cmake, so it can be shared between cmakev1 and
cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fe94c95ad6 feat(cmake/toolchain): include utilities.cmake from correct build system version
The toolchain files are using the remove_duplicated_flags function from
utilities.cmake. However, we want to avoid mixing utilities from cmakev1
and cmakev2. Use `IDF_BUILD_VER_TAG` to include utilities from the
currently used build system version.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Roland Dobai
f21b4c2381 change(version): Update version to 6.1-dev
Start of v6.1 development
2025-10-24 09:01:34 +02:00
Marius Vikhammer
a257812e14 feat(stdio): added esp_stdio component
esp_stdio contains everything the old esp_vfs_console contained (the vfs stdio glue layer)
as well as other functionality related to stdio (previously referred to as console)
2025-10-16 10:01:59 +08:00
Vincent-Dalstra
a36c8b8725 fix: Add quotes around node ID in dependency graph
Graphviz node ID's are represented as strings, that can only use a
restricted set of characters (characters, digits, and underscores), and
must not match a reserved keyword. These restrictions do not apply when
the string is wrapped in double quotes. This allows for component names
with dashes in them, for example.

Closes https://github.com/espressif/esp-idf/pull/17594
2025-10-08 19:55:21 +08:00