diff --git a/CMakeLists.txt b/CMakeLists.txt index 12170d526a..569f1a329e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,6 +206,12 @@ else() list(APPEND link_options "-Wl,--gc-sections") endif() +# SMP FreeRTOS user provided minimal idle hook. This allows the user to provide +# their own copy of vApplicationMinimalIdleHook() +if(CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK) + list(APPEND link_options "-Wl,--wrap=vApplicationMinimalIdleHook") +endif() + # Placing jump tables in flash would cause issues with code that required # to be placed in IRAM list(APPEND compile_options "-fno-jump-tables") diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/FreeRTOSConfig_smp.h b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/FreeRTOSConfig_smp.h index 6626101312..3321234f53 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/FreeRTOSConfig_smp.h +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/FreeRTOSConfig_smp.h @@ -148,7 +148,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b #endif #define configUSE_CORE_AFFINITY 1 #define configRUN_MULTIPLE_PRIORITIES 1 -#define configUSE_MINIMAL_IDLE_HOOK 1 +#define configUSE_MINIMAL_IDLE_HOOK 1 // This is always enabled to call IDF style idle hooks, by can be "--Wl,--wrap" if users enable CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK // ------------- Synchronization Primitives ---------------- @@ -183,7 +183,11 @@ This file get's pulled into assembly sources. Therefore, some includes need to b // ------------------------ Hooks -------------------------- +#if CONFIG_FREERTOS_USE_IDLE_HOOK #define configUSE_IDLE_HOOK 1 +#else +#define configUSE_IDLE_HOOK 0 +#endif #define configUSE_TICK_HOOK 1 #if CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE #define configCHECK_FOR_STACK_OVERFLOW 0 diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c index 029275b4da..d2ad0c5e50 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c @@ -613,19 +613,24 @@ void vApplicationTickHook( void ) } #endif -#if ( configUSE_IDLE_HOOK == 1 ) -void vApplicationIdleHook( void ) +#if CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK +/* +By default, the port uses vApplicationMinimalIdleHook() to run IDF style idle +hooks. However, users may also want to provide their own vApplicationMinimalIdleHook(). +In this case, we use to -Wl,--wrap option to wrap the user provided vApplicationMinimalIdleHook() +*/ +extern void __real_vApplicationMinimalIdleHook( void ); +void __wrap_vApplicationMinimalIdleHook( void ) { - esp_vApplicationIdleHook(); + esp_vApplicationIdleHook(); //Run IDF style hooks + __real_vApplicationMinimalIdleHook(); //Call the user provided vApplicationMinimalIdleHook() } -#endif - -#if ( configUSE_MINIMAL_IDLE_HOOK == 1 ) +#else // CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK void vApplicationMinimalIdleHook( void ) { - esp_vApplicationIdleHook(); + esp_vApplicationIdleHook(); //Run IDF style hooks } -#endif +#endif // CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK /* ---------------------------------------------- Misc Implementations ------------------------------------------------- * diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 342ae097f3..3d373723f4 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -215,6 +215,14 @@ menu "FreeRTOS" - The FreeRTOS idle hook is NOT the same as the ESP-IDF Idle Hook, but both can be enabled simultaneously. + config FREERTOS_USE_MINIMAL_IDLE_HOOK + bool "Use FreeRTOS minimal idle hook" + depends on FREERTOS_SMP + default n + help + - The application must provide the hook function ``void vApplicationMinimalIdleHook( void );`` + - ``vApplicationMinimalIdleHook()`` is called from FreeRTOS idle task(s) + config FREERTOS_USE_TICK_HOOK bool "Use FreeRTOS tick hook" default n