Description
Hardware:
Board: ESP32 Dev Module + w5500 chip
Core Installation version: 1.0.4
IDE name: Arduino IDE and Platform.io
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 921600
Computer OS: Windows 10
Description:
I have been trying to get the arduino webserver library or asyncwebserver library working over Ethernet with the built in Ethernet library for a few days now and failing miserably. I am using a w5500 Ethernet chip and it works fine in other projects using udp or tcp messages with no issue, using the exact same hardware setup. The issue arises as soon as i use either webserver library and call the begin function the esp32 crashes and reboots. Ive tried platformio and the arduino ide with the latest core, and 1.0.3 and results are the same.
Ive used the webserver examples for both libraries and both work perfectly fine over wifi, but as soon as i switch it to using Ethernet, crashes happen when begin is called.
I believe the issue stems from the esp32 core and some nonstandard implementations of the server begin function? Despite my attempts i have not been able to figure out how to fix this issue.
Any suggestions on what to try next? Any more information or data i could provide?
The sketch will crash in the same way even without the w5500 hardware attached so that to test and confirm all that is needed is a esp32 dev board. Ive attached one of the webserver examples modified for Ethernet instead of wifi.
Thanks for any assistance!
Sketch: (leave the backquotes for code formatting)
//Change the code below by your sketch
#include <Ethernet.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
IPAddress ip(192, 168, 10, 13); //failsafe ip
byte mac[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; //failsafe mac
AsyncWebServer server(80);
const char* PARAM_MESSAGE = "message";
void notFound(AsyncWebServerRequest *request) {
request->send(404, "text/plain", "Not found");
}
void setup(void) {
Serial.begin(115200);
setupEthernet();
Serial.print("IP address: ");
Serial.println(Ethernet.localIP());
delay(1000);
/*return index page which is stored in serverIndex */
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/plain", "Hello, world");
});
// Send a GET request to <IP>/get?message=<message>
server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
String message;
if (request->hasParam(PARAM_MESSAGE)) {
message = request->getParam(PARAM_MESSAGE)->value();
} else {
message = "No message sent";
}
request->send(200, "text/plain", "Hello, GET: " + message);
});
// Send a POST request to <IP>/post with a form field message set to <message>
server.on("/post", HTTP_POST, [](AsyncWebServerRequest *request){
String message;
if (request->hasParam(PARAM_MESSAGE, true)) {
message = request->getParam(PARAM_MESSAGE, true)->value();
} else {
message = "No message sent";
}
request->send(200, "text/plain", "Hello, POST: " + message);
});
server.onNotFound(notFound);
server.begin();
}
void loop(void) {
}
void setupEthernet(){
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
delay(25);
digitalWrite(4, HIGH); //enable the ethernet chip after resetting
Ethernet.init(5); //set our CS pin for ethernet
Ethernet.begin(mac, ip);
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println(F("Ethernet hardware not found"));
}
}
Debug Messages:
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
IP address: 192.168.10.13
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1442 (xQueueGenericReceive)- assert failed!
abort() was called at PC 0x40088071 on core 1
Backtrace: 0x4008b744:0x3ffb1da0 0x4008b975:0x3ffb1dc0 0x40088071:0x3ffb1de0 0x400f9556:0x3ffb1e20 0x400f9622:0x3ffb1e40 0x400ee000:0x3ffb1e60 0x400ee069:0x3ffb1e80 0x400ef5c0:0x3ffb1ea0 0x400ef6ac:0x3ffb1ed0 0x400d294d:0x3ffb1ef0 0x400d69ba:0x3ffb1f40 0x400d19e2:0x3ffb1f60 0x400d92cb:0x3ffb1fb0 0x40088385:0x3ffb1fd0
Rebooting...
Decoding stack results
0x4008b744: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155
0x4008b975: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170
0x40088071: xQueueGenericReceive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c line 1442
0x400f9556: sys_mutex_lock at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/port/esp32/freertos/sys_arch.c line 78
0x400f9622: sys_arch_protect at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/port/esp32/freertos/sys_arch.c line 469
0x400ee000: do_memp_malloc_pool at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/memp.c line 302
0x400ee069: memp_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/memp.c line 398
0x400ef5c0: tcp_alloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp.c line 1661
0x400ef6ac: tcp_new_ip_type at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp.c line 1782
0x400d294d: AsyncServer::begin() at C:\Users\Ivo\Documents\Arduino\libraries\AsyncTCP\src\AsyncTCP.cpp line 1274
0x400d69ba: AsyncWebServer::begin() at C:\Users\Ivo\Documents\Arduino\libraries\ESPAsyncWebServer\src\WebServer.cpp line 84
0x400d19e2: setup() at C:\Users\Ivo\Documents\Arduino\OTAWebUpdaterESPTEST/OTAWebUpdaterESPTEST.ino line 52
0x400d92cb: loopTask(void*) at C:\Users\Ivo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32\main.cpp line 14
0x40088385: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143