From 48a7f053d50ad5f0b0074c143ca59f3842ff037b Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 2 Feb 2024 23:38:00 +0800 Subject: [PATCH] feat(freertos/smp): Update other IDF components to be compatible with FreeRTOS v11.0.1 --- CMakeLists.txt | 6 ++--- components/esp_system/esp_system.c | 4 ++-- .../esp_system_unity_tests/main/test_sleep.c | 4 ++-- components/spi_flash/cache_utils.c | 24 +++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 153d9e24f0..8caae634f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,9 +223,9 @@ else() 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") +# their own copy of vApplicationPassiveIdleHook() +if(CONFIG_FREERTOS_USE_PASSIVE_IDLE_HOOK) + list(APPEND link_options "-Wl,--wrap=vApplicationPassiveIdleHook") endif() # Placing jump tables in flash would cause issues with code that required diff --git a/components/esp_system/esp_system.c b/components/esp_system/esp_system.c index d5cc6f5c06..bd80e2459f 100644 --- a/components/esp_system/esp_system.c +++ b/components/esp_system/esp_system.c @@ -52,13 +52,13 @@ void esp_restart(void) } } -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionDisable(NULL); #else // Disable scheduler on this core. vTaskSuspendAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) esp_restart_noos(); } diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c index 1bd7db14e3..c5f925c418 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c @@ -60,13 +60,13 @@ static void do_deep_sleep_from_app_cpu(void) xTaskCreatePinnedToCore(&deep_sleep_task, "ds", 2048, NULL, 5, NULL, 1); -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionDisable(NULL); #else // keep running some non-IRAM code vTaskSuspendAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) while (true) { ; diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index 862e57e5b5..7cf59ef6d5 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -118,7 +118,7 @@ void spi_flash_op_unlock(void) void IRAM_ATTR spi_flash_op_block_func(void *arg) { // Disable scheduler on this CPU -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) /* Note: FreeRTOS SMP has changed the behavior of scheduler suspension. But the vTaskPreemptionDisable() function should achieve the same affect as before (i.e., prevent the current task from being preempted). @@ -126,7 +126,7 @@ void IRAM_ATTR spi_flash_op_block_func(void *arg) vTaskPreemptionDisable(NULL); #else vTaskSuspendAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) // Restore interrupts that aren't located in IRAM esp_intr_noniram_disable(); uint32_t cpuid = (uint32_t) arg; @@ -142,13 +142,13 @@ void IRAM_ATTR spi_flash_op_block_func(void *arg) spi_flash_restore_cache(cpuid, s_flash_op_cache_state[cpuid]); // Restore interrupts that aren't located in IRAM esp_intr_noniram_enable(); -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionEnable(NULL); #else // Re-enable scheduler xTaskResumeAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) } void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void) @@ -187,13 +187,13 @@ void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu(void) // Busy loop and wait for spi_flash_op_block_func to disable cache // on the other CPU } -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionDisable(NULL); #else // Disable scheduler on the current CPU vTaskSuspendAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) // Can now set the priority back to the normal one prvTaskPriorityRestore(&SavedPriority); // This is guaranteed to run on CPU because the other CPU is now @@ -248,12 +248,12 @@ void IRAM_ATTR spi_flash_enable_interrupts_caches_and_other_cpu(void) // But esp_intr_noniram_enable has to be called on the same CPU which // called esp_intr_noniram_disable if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionEnable(NULL); #else xTaskResumeAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) } // Release API lock spi_flash_op_unlock(); @@ -290,26 +290,26 @@ void spi_flash_init_lock(void) void spi_flash_op_lock(void) { -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) { //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionDisable(NULL); } #else vTaskSuspendAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) } void spi_flash_op_unlock(void) { -#ifdef CONFIG_FREERTOS_SMP +#if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) { //Note: Scheduler suspension behavior changed in FreeRTOS SMP vTaskPreemptionEnable(NULL); } #else xTaskResumeAll(); -#endif // CONFIG_FREERTOS_SMP +#endif // #if ( ( CONFIG_FREERTOS_SMP ) && ( !CONFIG_FREERTOS_UNICORE ) ) }