diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index 6008b543e8..f3ab5a11e2 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -113,17 +113,10 @@ else() endif() endif() -# esp_timer is required by FreeRTOS when we use esp_timer_get_time() to do profiling -# [refactor-todo]: make this an optional requirement depending on CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER -# Note, many other components implicitly include esp_timer.h via freertos portmacro.h and some -# components implicitly depend on esp_timer via freertos. -set(required_components esp_timer) - idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${include_dirs} PRIV_INCLUDE_DIRS ${private_include_dirs} LDFRAGMENTS linker.lf - REQUIRES ${required_components} PRIV_REQUIRES soc esp_pm) idf_component_get_property(COMPONENT_DIR freertos COMPONENT_DIR) @@ -166,3 +159,9 @@ if(CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME) # [refactor-todo]: port.c esp_startup_start_app_common() calls esp_gdbstub_init() idf_component_optional_requires(PRIVATE esp_gdbstub) endif() + +if(CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER) + # [refactor-todo]: esp_timer is required by FreeRTOS when we use esp_timer_get_time() to do profiling + # Introduce a port wrapper function to avoid including esp_timer.h into the public header + idf_component_optional_requires(PUBLIC esp_timer) +endif() diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h index 4558a4f05b..5c1cd214a1 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/portmacro.h @@ -382,7 +382,6 @@ portmacro.h. Therefore, we need to keep these headers around for now to allow th #include #include #include "esp_attr.h" -#include "esp_timer.h" #include "esp_newlib.h" #include "esp_heap_caps.h" #include "esp_rom_sys.h" @@ -392,6 +391,11 @@ portmacro.h. Therefore, we need to keep these headers around for now to allow th #include #include +/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */ +#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER +#include "esp_timer.h" +#endif + #ifdef __cplusplus } #endif diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h index 253540b61d..bee5834be0 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h @@ -47,7 +47,6 @@ #include "esp_macros.h" #include "esp_attr.h" #include "esp_rom_sys.h" -#include "esp_timer.h" /* required for FreeRTOS run time stats */ #include "esp_heap_caps.h" #include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */ #include "esp_newlib.h" @@ -55,6 +54,11 @@ /* [refactor-todo] These includes are not directly used in this file. They are kept into to prevent a breaking change. Remove these. */ #include +/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */ +#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER +#include "esp_timer.h" +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h index 5d0d7e2f1d..edaf65ddb8 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h @@ -76,7 +76,6 @@ #include "esp_private/crosscore_int.h" #include "esp_macros.h" #include "esp_attr.h" -#include "esp_timer.h" /* required for esp_timer_get_time. [refactor-todo] make this common between archs */ #include "esp_newlib.h" /* required for esp_reent_init() in tasks.c */ #include "esp_heap_caps.h" #include "esp_rom_sys.h" @@ -88,6 +87,11 @@ #include #include +/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */ +#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER +#include "esp_timer.h" +#endif + #ifdef __cplusplus extern "C" { #endif