请问如何增加esp32s2 wifi stack 大小 “A stack overflow in task httpd has been detected”

abutwang
Posts: 5
Joined: Tue Jan 18, 2022 1:50 am

请问如何增加esp32s2 wifi stack 大小 “A stack overflow in task httpd has been detected”

Postby abutwang » Wed Feb 16, 2022 1:48 am

固件用的是4.3版本
模组是esp32s2 2M内存版本

代码如下
static esp_err_t image_handler(httpd_req_t *req)
{
ESP_LOGI(TAG, "Web GET begin\n");

uint16_t tmp[1000]={1};

char *json_data = (char *)heap_caps_calloc(80*63*10, sizeof(char), MALLOC_CAP_SPIRAM); ;
cJSON *message =cJSON_CreateObject();
cJSON *data=cJSON_CreateIntArray(tmp,1000);
cJSON_AddItemToObject(message,"data",data);

json_data = cJSON_Print(message);
printf(json_data);
ESP_LOGI(TAG, "Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());

httpd_resp_set_type(req, "application/json");
httpd_resp_set_hdr(req,"Access-Control-Allow-Origin","*");
httpd_resp_send(req,json_data,1000);

free(json_data);

return ESP_OK;
}


调试下来错误代码
[09:19:23.651] ***ERROR*** A stack overflow in task httpd has been detected.
[09:19:23.651]
[09:19:23.651] Backtrace:0x4002e1f7:0x3fff8a70 0x4002eaa1:0x3fff8a90 0x40031835:0x3fff8ab0 0x4003036e:0x3fff8b30 0x4002eb98:0x3fff8b50 0x4002eb4a:0x4001a690 |<-CORRUPTED

调整了
Max number of Wifi staic TX buffers 32
Default send buffer size 57440
没有找到stack 设置大小

麻烦高手指导一下谢谢

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: 请问如何增加esp32s2 wifi stack 大小 “A stack overflow in task httpd has been detected”

Postby ESP_YJM » Tue Mar 08, 2022 7:54 am

你这个是 httpd task 栈溢出了,有两个方式:
1. image_handle 里面不要使用这么大的数组,很容易导致栈溢出。
2. 调整栈大小,你代码搜一下:HTTPD_DEFAULT_CONFIG(esp_http_server.h)里将 stack_size 调大试试。

Who is online

Users browsing this forum: No registered users and 64 guests