From 4b0301989f10fa3adb9d9871f36bc5e07331b10c Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Fri, 5 Jun 2026 15:54:58 +0200 Subject: [PATCH] fix(cmakev2/bootloader): link bootloader_components discovered from EXTRA_COMPONENT_DIRS idf_build_executable only links the COMPONENTS list and its dependencies. However, bootloader_components provided by the application get discovered, but not linked. This MR forces the extra components for the bootloader to be linked to the bootloader binary as there is no way for the application to specify the same. --- .../bootloader/subproject/CMakeLists_v2.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/components/bootloader/subproject/CMakeLists_v2.txt b/components/bootloader/subproject/CMakeLists_v2.txt index 549dbd50775..231f315579b 100644 --- a/components/bootloader/subproject/CMakeLists_v2.txt +++ b/components/bootloader/subproject/CMakeLists_v2.txt @@ -120,9 +120,25 @@ idf_build_set_property(BOOTLOADER_LINKER_SCRIPT "${LD_DEFAULT_PATH}/bootloader.s # --------------------------------------------------------------------------- # Build the bootloader ELF # --------------------------------------------------------------------------- +# Build system v2 discovers components from EXTRA_COMPONENT_DIRS (the application's +# bootloader_components/ and BOOTLOADER_EXTRA_COMPONENT_DIRS entries) but does +# not link them as idf_build_executable only links the COMPONENTS list and its +# REQUIRES field; i.e, main and its dependencies. The application has no way +# to link the bootloader with these extra components. So promote every project_extra_components +# tagged component source to a root component here. +set(_bootloader_root_components main) +idf_build_get_property(_discovered_components COMPONENTS_DISCOVERED) +foreach(component IN LISTS _discovered_components) + idf_component_get_property(_src "${component}" COMPONENT_SOURCE) + if(_src STREQUAL "project_extra_components") + list(APPEND _bootloader_root_components ${component}) + endif() +endforeach() +list(REMOVE_DUPLICATES _bootloader_root_components) + idf_build_executable(bootloader_elf NAME bootloader - COMPONENTS main + COMPONENTS ${_bootloader_root_components} MAPFILE_TARGET bootloader_mapfile) # ---------------------------------------------------------------------------