From 914b0de7641cd46cec49196c6bb7262594db0f1e Mon Sep 17 00:00:00 2001 From: Laukik Hase Date: Fri, 25 Mar 2022 13:48:38 +0530 Subject: [PATCH] freertos: Indicate completed initialization for APP CPU with idle task hook Co-authored-by: Mahavir Jain --- .../FreeRTOS-Kernel/portable/port_common.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/freertos/FreeRTOS-Kernel/portable/port_common.c b/components/freertos/FreeRTOS-Kernel/portable/port_common.c index 8ae7ae504d..9b5d4af7f2 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/port_common.c +++ b/components/freertos/FreeRTOS-Kernel/portable/port_common.c @@ -19,6 +19,7 @@ #include "esp_memory_utils.h" #include "esp_freertos_hooks.h" #include "sdkconfig.h" +#include "esp_freertos_hooks.h" #if CONFIG_IDF_TARGET_ESP32 #include "esp32/spiram.h" @@ -79,13 +80,24 @@ void esp_startup_start_app_common(void) (void)res; } +#if !CONFIG_FREERTOS_UNICORE +static volatile bool s_app_cpu_startup_done = false; +static bool s_app_cpu_startup_idle_hook_cb(void) +{ + s_app_cpu_startup_done = true; + return true; +} +#endif + static void main_task(void* args) { #if !CONFIG_FREERTOS_UNICORE // Wait for FreeRTOS initialization to finish on APP CPU, before replacing its startup stack - while (port_xSchedulerRunning[1] == 0) { + esp_register_freertos_idle_hook_for_cpu(s_app_cpu_startup_idle_hook_cb, 1); + while (!s_app_cpu_startup_done) { ; } + esp_deregister_freertos_idle_hook_for_cpu(s_app_cpu_startup_idle_hook_cb, 1); #endif // [refactor-todo] check if there is a way to move the following block to esp_system startup