整理任务使用的cpu
新增配置: CONFIG_TQ_NETWORK_TASK_CORE=0 CONFIG_TQ_LOCAL_TASK_CORE=1 网络类任务默认固定到 Core 0: cp_ws_wait cp_wifi_state cp_fortune mm_autostart mm_watchdog mm_ws_ordered mm_ws_stop lan_http 本地类任务默认固定到 Core 1: cp_model_cmd cp_direction cp_lcd_render cp_task_monitor cp_system_event cp_key_input factory_cli mm_local_evt 已有音频任务保持现有配置: CONFIG_MULTIMODAL_AUDIO_TASK_CORE=1
This commit is contained in:
@@ -37,6 +37,16 @@
|
||||
#define FACTORY_CLI_START_WAIT_STEP_MS 20
|
||||
#define FACTORY_CLI_START_GATE_WAIT_MS 5000
|
||||
|
||||
#ifndef CONFIG_TQ_LOCAL_TASK_CORE
|
||||
#define CONFIG_TQ_LOCAL_TASK_CORE 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_TQ_LOCAL_TASK_CORE < 0
|
||||
#define FACTORY_CLI_TASK_CORE tskNO_AFFINITY
|
||||
#else
|
||||
#define FACTORY_CLI_TASK_CORE ((BaseType_t)CONFIG_TQ_LOCAL_TASK_CORE)
|
||||
#endif
|
||||
|
||||
static const char *TAG = "cp_factory_cli";
|
||||
|
||||
static TaskHandle_t s_worker_task;
|
||||
@@ -496,12 +506,13 @@ esp_err_t control_plane_factory_cli_start(void)
|
||||
}
|
||||
|
||||
TaskHandle_t worker_task = NULL;
|
||||
BaseType_t ok = xTaskCreate(factory_cli_worker_entry,
|
||||
"factory_cli",
|
||||
FACTORY_CLI_WORKER_STACK_BYTES,
|
||||
NULL,
|
||||
FACTORY_CLI_WORKER_PRIORITY,
|
||||
&worker_task);
|
||||
BaseType_t ok = xTaskCreatePinnedToCore(factory_cli_worker_entry,
|
||||
"factory_cli",
|
||||
FACTORY_CLI_WORKER_STACK_BYTES,
|
||||
NULL,
|
||||
FACTORY_CLI_WORKER_PRIORITY,
|
||||
&worker_task,
|
||||
FACTORY_CLI_TASK_CORE);
|
||||
if (ok != pdPASS) {
|
||||
factory_cli_finish_start(NULL);
|
||||
ESP_LOGE(TAG, "Failed to start factory CLI worker");
|
||||
|
||||
@@ -48,6 +48,16 @@
|
||||
#define CONFIG_TQ_KEY_INPUT_POLL_MS 20
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TQ_LOCAL_TASK_CORE
|
||||
#define CONFIG_TQ_LOCAL_TASK_CORE 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_TQ_LOCAL_TASK_CORE < 0
|
||||
#define CONTROL_PLANE_KEY_INPUT_TASK_CORE tskNO_AFFINITY
|
||||
#else
|
||||
#define CONTROL_PLANE_KEY_INPUT_TASK_CORE ((BaseType_t)CONFIG_TQ_LOCAL_TASK_CORE)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MULTIMODAL_PTT_BUTTON_PULLDOWN
|
||||
#define CONFIG_MULTIMODAL_PTT_BUTTON_PULLDOWN 0
|
||||
#endif
|
||||
@@ -464,12 +474,13 @@ esp_err_t control_plane_start_key_input_task(void)
|
||||
}
|
||||
|
||||
s_stop_requested = false;
|
||||
BaseType_t created = xTaskCreate(control_plane_key_input_task,
|
||||
"cp_key_input",
|
||||
CONFIG_TQ_KEY_INPUT_TASK_STACK,
|
||||
NULL,
|
||||
5,
|
||||
&s_key_input_task);
|
||||
BaseType_t created = xTaskCreatePinnedToCore(control_plane_key_input_task,
|
||||
"cp_key_input",
|
||||
CONFIG_TQ_KEY_INPUT_TASK_STACK,
|
||||
NULL,
|
||||
5,
|
||||
&s_key_input_task,
|
||||
CONTROL_PLANE_KEY_INPUT_TASK_CORE);
|
||||
if (created != pdPASS) {
|
||||
s_key_input_task = NULL;
|
||||
return ESP_ERR_NO_MEM;
|
||||
|
||||
@@ -74,6 +74,26 @@
|
||||
#define CONFIG_TQ_TASK_MONITOR_MAX_TASKS 64
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TQ_NETWORK_TASK_CORE
|
||||
#define CONFIG_TQ_NETWORK_TASK_CORE 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TQ_LOCAL_TASK_CORE
|
||||
#define CONFIG_TQ_LOCAL_TASK_CORE 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_TQ_NETWORK_TASK_CORE < 0
|
||||
#define CONTROL_PLANE_NETWORK_TASK_CORE tskNO_AFFINITY
|
||||
#else
|
||||
#define CONTROL_PLANE_NETWORK_TASK_CORE ((BaseType_t)CONFIG_TQ_NETWORK_TASK_CORE)
|
||||
#endif
|
||||
|
||||
#if CONFIG_TQ_LOCAL_TASK_CORE < 0
|
||||
#define CONTROL_PLANE_LOCAL_TASK_CORE tskNO_AFFINITY
|
||||
#else
|
||||
#define CONTROL_PLANE_LOCAL_TASK_CORE ((BaseType_t)CONFIG_TQ_LOCAL_TASK_CORE)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FORTUNE_SNTP_SERVER
|
||||
#define CONFIG_FORTUNE_SNTP_SERVER "ntp.aliyun.com"
|
||||
#endif
|
||||
@@ -358,6 +378,7 @@ static esp_err_t control_plane_create_task(TaskFunction_t task,
|
||||
const char *name,
|
||||
uint32_t stack_size,
|
||||
UBaseType_t priority,
|
||||
BaseType_t core_id,
|
||||
TaskHandle_t *out_handle)
|
||||
{
|
||||
if (task == NULL || out_handle == NULL) {
|
||||
@@ -372,7 +393,13 @@ static esp_err_t control_plane_create_task(TaskFunction_t task,
|
||||
ctx->task_with_caps = false;
|
||||
|
||||
TaskHandle_t task_handle = NULL;
|
||||
if (xTaskCreate(control_plane_task_start_gate, name, stack_size, ctx, priority, &task_handle) != pdPASS) {
|
||||
if (xTaskCreatePinnedToCore(control_plane_task_start_gate,
|
||||
name,
|
||||
stack_size,
|
||||
ctx,
|
||||
priority,
|
||||
&task_handle,
|
||||
core_id) != pdPASS) {
|
||||
free(ctx);
|
||||
ESP_LOGE(TAG, "Task create failed: %s", name);
|
||||
return ESP_ERR_NO_MEM;
|
||||
@@ -387,6 +414,7 @@ static esp_err_t control_plane_create_task_psram_first(TaskFunction_t task,
|
||||
const char *name,
|
||||
uint32_t stack_size,
|
||||
UBaseType_t priority,
|
||||
BaseType_t core_id,
|
||||
TaskHandle_t *out_handle)
|
||||
{
|
||||
if (task == NULL || out_handle == NULL) {
|
||||
@@ -408,7 +436,7 @@ static esp_err_t control_plane_create_task_psram_first(TaskFunction_t task,
|
||||
ctx,
|
||||
priority,
|
||||
&task_handle,
|
||||
tskNO_AFFINITY,
|
||||
core_id,
|
||||
MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
if (created != pdPASS) {
|
||||
ESP_LOGW(TAG, "Task create with PSRAM stack failed: %s, fallback to internal stack", name);
|
||||
@@ -418,17 +446,18 @@ static esp_err_t control_plane_create_task_psram_first(TaskFunction_t task,
|
||||
ctx,
|
||||
priority,
|
||||
&task_handle,
|
||||
tskNO_AFFINITY,
|
||||
core_id,
|
||||
MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
}
|
||||
#else
|
||||
ctx->task_with_caps = false;
|
||||
BaseType_t created = xTaskCreate(control_plane_task_start_gate,
|
||||
name,
|
||||
stack_size,
|
||||
ctx,
|
||||
priority,
|
||||
&task_handle);
|
||||
BaseType_t created = xTaskCreatePinnedToCore(control_plane_task_start_gate,
|
||||
name,
|
||||
stack_size,
|
||||
ctx,
|
||||
priority,
|
||||
&task_handle,
|
||||
core_id);
|
||||
#endif
|
||||
if (created != pdPASS) {
|
||||
free(ctx);
|
||||
@@ -718,6 +747,7 @@ static esp_err_t control_plane_schedule_websocket_wait_task(void)
|
||||
"cp_ws_wait",
|
||||
CONTROL_PLANE_WS_WAIT_TASK_STACK_SIZE,
|
||||
4,
|
||||
CONTROL_PLANE_NETWORK_TASK_CORE,
|
||||
&s_ws_wait_task);
|
||||
portENTER_CRITICAL(&s_runtime_lock);
|
||||
s_ws_wait_task_starting = false;
|
||||
@@ -1453,6 +1483,7 @@ esp_err_t control_plane_start_runtime_workers(void)
|
||||
"cp_model_cmd",
|
||||
CONTROL_PLANE_MODEL_CMD_TASK_STACK_SIZE,
|
||||
5,
|
||||
CONTROL_PLANE_LOCAL_TASK_CORE,
|
||||
&s_model_cmd_task);
|
||||
if (task_err != ESP_OK) {
|
||||
control_plane_stop_runtime_workers();
|
||||
@@ -1473,6 +1504,7 @@ esp_err_t control_plane_start_runtime_workers(void)
|
||||
"cp_direction",
|
||||
CONTROL_PLANE_DIRECTION_TASK_STACK_SIZE,
|
||||
5,
|
||||
CONTROL_PLANE_LOCAL_TASK_CORE,
|
||||
&s_direction_console_task);
|
||||
if (task_err != ESP_OK) {
|
||||
control_plane_stop_runtime_workers();
|
||||
@@ -1486,6 +1518,7 @@ esp_err_t control_plane_start_runtime_workers(void)
|
||||
"cp_lcd_render",
|
||||
CONTROL_PLANE_LCD_RENDER_LOOP_TASK_STACK_SIZE,
|
||||
4,
|
||||
CONTROL_PLANE_LOCAL_TASK_CORE,
|
||||
&s_lcd_render_loop_task);
|
||||
if (task_err != ESP_OK) {
|
||||
control_plane_stop_runtime_workers();
|
||||
@@ -1501,6 +1534,7 @@ esp_err_t control_plane_start_runtime_workers(void)
|
||||
"cp_wifi_state",
|
||||
CONTROL_PLANE_WIFI_STATE_TASK_STACK_SIZE,
|
||||
4,
|
||||
CONTROL_PLANE_NETWORK_TASK_CORE,
|
||||
&s_wifi_state_task);
|
||||
if (task_err != ESP_OK) {
|
||||
control_plane_stop_runtime_workers();
|
||||
@@ -1514,6 +1548,7 @@ esp_err_t control_plane_start_runtime_workers(void)
|
||||
"cp_task_monitor",
|
||||
CONTROL_PLANE_TASK_MONITOR_TASK_STACK_SIZE,
|
||||
3,
|
||||
CONTROL_PLANE_LOCAL_TASK_CORE,
|
||||
&s_task_monitor_task);
|
||||
if (task_err != ESP_OK) {
|
||||
control_plane_stop_runtime_workers();
|
||||
@@ -1541,6 +1576,7 @@ esp_err_t control_plane_start_runtime_workers(void)
|
||||
"cp_fortune",
|
||||
CONTROL_PLANE_FORTUNE_TASK_STACK_SIZE,
|
||||
4,
|
||||
CONTROL_PLANE_NETWORK_TASK_CORE,
|
||||
&s_daily_fortune_task);
|
||||
if (task_err != ESP_OK) {
|
||||
control_plane_stop_runtime_workers();
|
||||
|
||||
@@ -30,6 +30,16 @@
|
||||
#define CONFIG_TQ_SYSTEM_EVENT_TASK_STACK 4096
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TQ_LOCAL_TASK_CORE
|
||||
#define CONFIG_TQ_LOCAL_TASK_CORE 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_TQ_LOCAL_TASK_CORE < 0
|
||||
#define CONTROL_PLANE_SYSTEM_EVENT_TASK_CORE tskNO_AFFINITY
|
||||
#else
|
||||
#define CONTROL_PLANE_SYSTEM_EVENT_TASK_CORE ((BaseType_t)CONFIG_TQ_LOCAL_TASK_CORE)
|
||||
#endif
|
||||
|
||||
static const char *TAG = "cp_system_event";
|
||||
|
||||
static QueueHandle_t s_system_event_queue;
|
||||
@@ -192,12 +202,13 @@ esp_err_t control_plane_start_system_event_task(void)
|
||||
}
|
||||
|
||||
s_stop_requested = false;
|
||||
BaseType_t created = xTaskCreate(control_plane_system_event_task,
|
||||
"cp_system_event",
|
||||
CONFIG_TQ_SYSTEM_EVENT_TASK_STACK,
|
||||
NULL,
|
||||
4,
|
||||
&s_system_event_task);
|
||||
BaseType_t created = xTaskCreatePinnedToCore(control_plane_system_event_task,
|
||||
"cp_system_event",
|
||||
CONFIG_TQ_SYSTEM_EVENT_TASK_STACK,
|
||||
NULL,
|
||||
4,
|
||||
&s_system_event_task,
|
||||
CONTROL_PLANE_SYSTEM_EVENT_TASK_CORE);
|
||||
if (created != pdPASS) {
|
||||
s_system_event_task = NULL;
|
||||
return ESP_ERR_NO_MEM;
|
||||
|
||||
Reference in New Issue
Block a user