From 6928db7670e5a3ecd9411081065989ba66d74fe4 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sat, 27 Feb 2021 20:13:01 +0100 Subject: [PATCH] Allow selection of different core for main task Closes https://github.com/espressif/esp-idf/pull/6627 --- .../bootloader/subproject/CMakeLists.txt | 2 ++ components/esp_system/Kconfig | 23 +++++++++++++++++++ components/esp_system/include/esp_task.h | 1 + components/freertos/port/port_common.c | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index b647587f6c..bfbb1fc20c 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -15,11 +15,13 @@ if(NOT IDF_TARGET) "in by the parent build process.") endif() +# A number of these components are implemented as config-only when built in the bootloader set(COMPONENTS bootloader esptool_py esp_hw_support esp_system + freertos hal partition_table soc diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index 486c8cde45..19ea93b7fe 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -143,6 +143,29 @@ menu "ESP System Settings" which calls app_main(). If app_main() returns then this task is deleted and its stack memory is freed. + choice ESP_MAIN_TASK_AFFINITY + prompt "Main task core affinity" + default ESP_MAIN_TASK_AFFINITY_CPU0 + help + Configure the "main task" core affinity. This is the used core of the task + which calls app_main(). If app_main() returns then this task is deleted. + + config ESP_MAIN_TASK_AFFINITY_CPU0 + bool "CPU0" + config ESP_MAIN_TASK_AFFINITY_CPU1 + bool "CPU1" + depends on !FREERTOS_UNICORE + config ESP_MAIN_TASK_AFFINITY_NO_AFFINITY + bool "No affinity" + + endchoice + + config ESP_MAIN_TASK_AFFINITY + hex + default 0x0 if ESP_MAIN_TASK_AFFINITY_CPU0 + default 0x1 if ESP_MAIN_TASK_AFFINITY_CPU1 + default FREERTOS_NO_AFFINITY if ESP_MAIN_TASK_AFFINITY_NO_AFFINITY + config ESP_MINIMAL_SHARED_STACK_SIZE int "Minimal allowed size for shared stack" default 2048 diff --git a/components/esp_system/include/esp_task.h b/components/esp_system/include/esp_task.h index 06ddd606cc..105de5994c 100644 --- a/components/esp_system/include/esp_task.h +++ b/components/esp_system/include/esp_task.h @@ -55,5 +55,6 @@ #define ESP_TASK_TCPIP_STACK (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) #define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1) #define ESP_TASK_MAIN_STACK (CONFIG_ESP_MAIN_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE) +#define ESP_TASK_MAIN_CORE CONFIG_ESP_MAIN_TASK_AFFINITY #endif diff --git a/components/freertos/port/port_common.c b/components/freertos/port/port_common.c index 293f824ed8..8a7984ea29 100644 --- a/components/freertos/port/port_common.c +++ b/components/freertos/port/port_common.c @@ -81,7 +81,7 @@ void esp_startup_start_app_common(void) portBASE_TYPE res = xTaskCreatePinnedToCore(&main_task, "main", ESP_TASK_MAIN_STACK, NULL, - ESP_TASK_MAIN_PRIO, NULL, 0); + ESP_TASK_MAIN_PRIO, NULL, ESP_TASK_MAIN_CORE); assert(res == pdTRUE); (void)res; }