From 56b2414dee312ca66a5a609873cfe7a184b08e70 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 25 May 2026 12:04:40 +0200 Subject: [PATCH 1/4] fix(esp_tee): Stop esp_tee subproject to be built with build system v2 - Unset IDF_BUILD_V2 in subproject/CMakeLists.txt before including project.cmake so the nested esp_tee ExternalProject cmake stays on cmakev1. - Read PARTITION_TABLE_BIN_PATH as a generator expression under IDF_BUILD_V2 to defer the lookup to CMake's generate phase. --- components/esp_tee/project_include.cmake | 10 +++++++++- components/esp_tee/subproject/CMakeLists.txt | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/esp_tee/project_include.cmake b/components/esp_tee/project_include.cmake index 46fd4fbfe8c..d08b07ee346 100644 --- a/components/esp_tee/project_include.cmake +++ b/components/esp_tee/project_include.cmake @@ -8,7 +8,15 @@ idf_build_get_property(project_dir PROJECT_DIR) idf_build_get_property(non_os_build NON_OS_BUILD) idf_build_get_property(custom_secure_service_dir CUSTOM_SECURE_SERVICE_COMPONENT_DIR) idf_build_get_property(custom_secure_service_component CUSTOM_SECURE_SERVICE_COMPONENT) -idf_build_get_property(partition_table_bin PARTITION_TABLE_BIN_PATH) + +if(IDF_BUILD_V2) + # Under build system v2, partition_table/project_include.cmake may run + # after this file, so PARTITION_TABLE_BIN_PATH is not yet set. Defer the + # read to CMake's generate phase via a generator expression. + idf_build_get_property(partition_table_bin PARTITION_TABLE_BIN_PATH GENERATOR_EXPRESSION) +else() + idf_build_get_property(partition_table_bin PARTITION_TABLE_BIN_PATH) +endif() if(NOT CONFIG_SECURE_ENABLE_TEE OR non_os_build) return() diff --git a/components/esp_tee/subproject/CMakeLists.txt b/components/esp_tee/subproject/CMakeLists.txt index 8121e814578..0635a5a37b8 100644 --- a/components/esp_tee/subproject/CMakeLists.txt +++ b/components/esp_tee/subproject/CMakeLists.txt @@ -33,6 +33,12 @@ list(APPEND COMPONENTS attestation tee_flash_mgr tee_ota_ops tee_sec_storage) include_directories("${SECURE_SERVICE_HEADERS_DIR}") +# The TEE subproject is not yet ported to build system v2. +# Explicitly clear the IDF_BUILD_V2 environment variable so that +# tools/cmake/project.cmake does not activate the cmakev2 shim when +# the parent build was invoked with IDF_BUILD_V2=1. +unset(ENV{IDF_BUILD_V2}) + include("${IDF_PATH}/tools/cmake/project.cmake") set(common_req esp_common esp_hw_support esp_rom freertos hal log esp_libc soc spi_flash) From 2e2c5d1bf234fea8b8760d7b3f590d58709342c5 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 25 May 2026 12:05:42 +0200 Subject: [PATCH 2/4] change(esptool_py): hide serial flasher menu on linux target The linux host_test target has no real flash, so the "Serial flasher config" menu's options are meaningless there. Gate the menu on !IDF_TARGET_LINUX so its symbols stay undefined on linux. --- components/esptool_py/Kconfig.projbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esptool_py/Kconfig.projbuild b/components/esptool_py/Kconfig.projbuild index 2df271b95f0..5d763177743 100644 --- a/components/esptool_py/Kconfig.projbuild +++ b/components/esptool_py/Kconfig.projbuild @@ -1,5 +1,5 @@ menu "Serial flasher config" - depends on !APP_BUILD_TYPE_PURE_RAM_APP + depends on !APP_BUILD_TYPE_PURE_RAM_APP && !IDF_TARGET_LINUX config ESPTOOLPY_NO_STUB bool "Disable download stub" From 14173c4d1b187d0a03f7e3170c0eb8014a35568f Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 18 May 2026 13:35:18 +0200 Subject: [PATCH 3/4] fix(xtensa): detect freertos exclusion via __COMPONENT_REQUIRES_COMMON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The baremetal RTOS stub gating tested the invisible-bool CONFIG_FREERTOS_PORT, which can be set even when freertos is outside the build closure (e.g. the G0 test app). Query __COMPONENT_REQUIRES_COMMON directly — it is the surface those apps use to declare their closure. --- components/xtensa/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/xtensa/CMakeLists.txt b/components/xtensa/CMakeLists.txt index 65542191571..08e230aa31e 100644 --- a/components/xtensa/CMakeLists.txt +++ b/components/xtensa/CMakeLists.txt @@ -50,7 +50,13 @@ if(NOT BOOTLOADER_BUILD) list(APPEND srcs "xtensa_loadstore_handler.S") endif() - if(NOT CONFIG_FREERTOS_PORT) + # xtensa_rtos.h is provided by freertos when it is in the build closure. + # Under build system v2 every component's Kconfig is processed, so + # CONFIG_FREERTOS_PORT is set even when an app (e.g. g0_components) + # removes freertos from __COMPONENT_REQUIRES_COMMON. Inspect the + # common-requires list directly to detect the actual closure. + idf_build_get_property(__common_reqs __COMPONENT_REQUIRES_COMMON) + if(NOT "freertos" IN_LIST __common_reqs) # No RTOS provided. Use default bare metal stubs (to pass G0 build test) list(APPEND srcs "baremetal/xtensa_rtos_bm.S") From 29f6318b02858898b0706e54a6d581f84034081d Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 25 May 2026 14:40:49 +0200 Subject: [PATCH 4/4] fix(esp_hw_support): move linux spinlock.h to esp_hw_support/include/linux Moved the linux spinlock.h stub into esp_hw_support/include/linux. esp_hw_support's INCLUDE_DIRS already places include/linux before include, so the correct include files are picked up for the linux target. - Drop the FreeRTOS-Kernel-SMP linux spinlock.h duplicate. - rv_decode_test: use PRIV_REQUIRES esp_hw_support instead of hardcoding component include paths. --- .../rv_decode/main/CMakeLists.txt | 2 +- .../include/linux}/spinlock.h | 0 .../portable/linux/include/spinlock.h | 59 ------------------- 3 files changed, 1 insertion(+), 60 deletions(-) rename components/{freertos/FreeRTOS-Kernel/portable/linux/include => esp_hw_support/include/linux}/spinlock.h (100%) delete mode 100644 components/freertos/FreeRTOS-Kernel-SMP/portable/linux/include/spinlock.h diff --git a/components/esp_gdbstub/test_gdbstub_host/rv_decode/main/CMakeLists.txt b/components/esp_gdbstub/test_gdbstub_host/rv_decode/main/CMakeLists.txt index 3ddae3eb532..a1d645542cd 100644 --- a/components/esp_gdbstub/test_gdbstub_host/rv_decode/main/CMakeLists.txt +++ b/components/esp_gdbstub/test_gdbstub_host/rv_decode/main/CMakeLists.txt @@ -5,10 +5,10 @@ idf_component_register(SRCS "../../../private_include" "../../../include" "../../../src/port/riscv/include" - "../../../../esp_hw_support/include" "../../../../soc/esp32c3/include" "../../../../esp_common/include" "../../../../riscv/include" + PRIV_REQUIRES esp_hw_support WHOLE_ARCHIVE) # Currently 'main' for IDF_TARGET=linux is defined in freertos component. diff --git a/components/freertos/FreeRTOS-Kernel/portable/linux/include/spinlock.h b/components/esp_hw_support/include/linux/spinlock.h similarity index 100% rename from components/freertos/FreeRTOS-Kernel/portable/linux/include/spinlock.h rename to components/esp_hw_support/include/linux/spinlock.h diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/include/spinlock.h b/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/include/spinlock.h deleted file mode 100644 index 99514d5cac0..00000000000 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/include/spinlock.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * This file provides only very simple stubs to build IDF-based FreeRTOSes which use spinlocks on Linux. - */ -#pragma once - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define SPINLOCK_FREE 0xB33FFFFF -#define SPINLOCK_WAIT_FOREVER (-1) -#define SPINLOCK_NO_WAIT 0 -#define SPINLOCK_INITIALIZER {.owner = SPINLOCK_FREE,.count = 0} -#define CORE_ID_REGVAL_XOR_SWAP (0xCDCD ^ 0xABAB) - -/** - * @brief Spinlock object - * Owner: - * - Set to 0 if uninitialized - * - Set to portMUX_FREE_VAL when free - * - Set to CORE_ID_REGVAL_PRO or CORE_ID_REGVAL_AP when locked - * - Any other value indicates corruption - * Count: - * - 0 if unlocked - * - Recursive count if locked - * - * @note The simulator is single-core, hence, it doesn't have a proper spinlock implementation. - * @note Keep portMUX_INITIALIZER_UNLOCKED in sync with this struct - */ -typedef struct { - uint32_t owner; - uint32_t count; -}spinlock_t; - -static inline void __attribute__((always_inline)) spinlock_initialize(spinlock_t *lock) -{ -} - -static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *lock, int32_t timeout) -{ - return true; -} - -static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *lock) -{ -} - -#ifdef __cplusplus -} -#endif