Skip to content

Commit 44c3b0a

Browse files
committed
Merge branch 'bugfix/console_example_stack_overflow' into 'master'
Increase event task stack size to fix console example stack overflow See merge request idf/esp-idf!1879
2 parents 5684328 + 206eada commit 44c3b0a

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

components/esp32/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ config SYSTEM_EVENT_QUEUE_SIZE
281281

282282
config SYSTEM_EVENT_TASK_STACK_SIZE
283283
int "Event loop task stack size"
284-
default 2048
284+
default 2304
285285
help
286286
Config system event task stack size in different application.
287287

components/tcpip_adapter/include/tcpip_adapter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ typedef struct tcpip_adapter_dns_param_s {
184184
msg.data = (void*)(_data);\
185185
msg.api_fn = (_fn);\
186186
if (TCPIP_ADAPTER_IPC_REMOTE == tcpip_adapter_ipc_check(&msg)) {\
187-
ESP_LOGD(TAG, "check: remote, if=%d fn=%p\n", (_if), (_fn));\
187+
ESP_LOGV(TAG, "check: remote, if=%d fn=%p\n", (_if), (_fn));\
188188
return msg.ret;\
189189
} else {\
190-
ESP_LOGD(TAG, "check: local, if=%d fn=%p\n", (_if), (_fn));\
190+
ESP_LOGV(TAG, "check: local, if=%d fn=%p\n", (_if), (_fn));\
191191
}\
192192
}while(0)
193193

components/tcpip_adapter/tcpip_adapter_lwip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static sys_sem_t api_sync_sem = NULL;
6767
static bool tcpip_inited = false;
6868
static sys_sem_t api_lock_sem = NULL;
6969
extern sys_thread_t g_lwip_task;
70-
#define TAG "tcpip_adapter"
70+
static const char* TAG = "tcpip_adapter";
7171

7272
static void tcpip_adapter_api_cb(void* api_msg)
7373
{
@@ -79,7 +79,7 @@ static void tcpip_adapter_api_cb(void* api_msg)
7979
}
8080

8181
msg->ret = msg->api_fn(msg);
82-
ESP_LOGD(TAG, "call api in lwip: ret=0x%x, give sem", msg->ret);
82+
ESP_LOGV(TAG, "call api in lwip: ret=0x%x, give sem", msg->ret);
8383
sys_sem_signal(&api_sync_sem);
8484

8585
return;

examples/system/console/main/cmd_system.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,29 @@
2020
#include "freertos/FreeRTOS.h"
2121
#include "freertos/task.h"
2222
#include "soc/rtc_cntl_reg.h"
23+
#include "sdkconfig.h"
24+
25+
#ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
26+
#define WITH_TASKS_INFO 1
27+
#endif
2328

2429
static void register_free();
2530
static void register_restart();
2631
static void register_deep_sleep();
2732
static void register_make();
33+
#if WITH_TASKS_INFO
34+
static void register_tasks();
35+
#endif
2836

2937
void register_system()
3038
{
3139
register_free();
3240
register_restart();
3341
register_deep_sleep();
3442
register_make();
43+
#if WITH_TASKS_INFO
44+
register_tasks();
45+
#endif
3546
}
3647

3748
/** 'restart' command restarts the program */
@@ -72,6 +83,36 @@ static void register_free()
7283
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
7384
}
7485

86+
/** 'tasks' command prints the list of tasks and related information */
87+
#if WITH_TASKS_INFO
88+
89+
static int tasks_info(int argc, char** argv)
90+
{
91+
const size_t bytes_per_task = 40; /* see vTaskList description */
92+
char* task_list_buffer = malloc(uxTaskGetNumberOfTasks() * bytes_per_task);
93+
if (task_list_buffer == NULL) {
94+
ESP_LOGE(__func__, "failed to allocate buffer for vTaskList output");
95+
return 1;
96+
}
97+
vTaskList(task_list_buffer);
98+
fputs(task_list_buffer, stdout);
99+
free(task_list_buffer);
100+
return 0;
101+
}
102+
103+
static void register_tasks()
104+
{
105+
const esp_console_cmd_t cmd = {
106+
.command = "tasks",
107+
.help = "Get information about running tasks",
108+
.hint = NULL,
109+
.func = &tasks_info,
110+
};
111+
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
112+
}
113+
114+
#endif // WITH_TASKS_INFO
115+
75116
/** 'deep_sleep' command puts the chip into deep sleep mode */
76117

77118
static struct {

examples/system/console/sdkconfig.defaults

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y
33
CONFIG_LOG_BOOTLOADER_LEVEL=2
44

55
# Increase main task stack size
6-
CONFIG_MAIN_TASK_STACK_SIZE=6144
6+
CONFIG_MAIN_TASK_STACK_SIZE=7168
77

88
# Enable filesystem
99
CONFIG_PARTITION_TABLE_CUSTOM=y
1010
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
1111
CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET=0x10000
1212
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
1313
CONFIG_APP_OFFSET=0x10000
14+
15+
# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
16+
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
17+
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y

0 commit comments

Comments
 (0)