Allow selection of different core for main task

Closes https://github.com/espressif/esp-idf/pull/6627
This commit is contained in:
0xFEEDC0DE64 2021-02-27 20:13:01 +01:00 committed by Angus Gratton
parent ffe5e45c77
commit 6928db7670
4 changed files with 27 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}