Skip to content

Ethernet.begin() will crash the board with interesting debug message. #6393

Closed
@zekageri

Description

@zekageri

Board

esp-wrover-kit

Device Description

It is a custom PCB but it can be reproduced with any other.

Hardware Configuration

Ethernet

Version

latest master

IDE Name

Platform IO

Operating System

Windows 10

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

115200

Description

Upgraded to the latest arduino-esp32 and suddenly the ethernet callback is crashing my board.

Sketch

#define ETH_PHY_ADDR  1
#define PIN_PHY_POWER 17
#define PIN_SMI_MDC   23
#define PIN_SMI_MDIO  18

void ethEvent(WiFiEvent_t event){
    if( event == ARDUINO_EVENT_ETH_START ){
        ETH.setHostname(hsh_fileSystem.config.hostname);
    }else if( event == ARDUINO_EVENT_ETH_GOT_IP ){
                Serial.printf("\nConnected to Ethernet\n");
                Serial.printf("NS - IP:\t%s\n",          ETH.localIP().toString().c_str());
                Serial.printf("NS - MAC:\t%s\n",         ETH.macAddress().c_str());
                Serial.printf("NS - Host:\t%s\n",        ETH.getHostname());
    }else if( event == ARDUINO_EVENT_ETH_DISCONNECTED ){
       Serial.println("\nNS - Ethernet disconnected");
    }
}

void setup(){
ETH.begin(
        ETH_PHY_ADDR,
        PIN_PHY_POWER,
        PIN_SMI_MDC,
        PIN_SMI_MDIO,
        ETH_PHY_LAN8720,
        ETH_CLK_MODE
    );
    WiFi.onEvent(ethEvent);
}

Debug Message

Core  0 register dump:
PC      : 0x40091ff8  PS      : 0x00060333  A0      : 0x80093e34  A1      : 0x3ffdc7e0
A2      : 0xdf010000  A3      : 0xb33fffff  A4      : 0x0000abab  A5      : 0x00060323  
A6      : 0x00060320  A7      : 0x0000cdcd  A8      : 0x0000cdcd  A9      : 0xffffffff
A10     : 0x3ffe1270  A11     : 0x00000004  A12     : 0x00000004  A13     : 0x3ffb9270  
A14     : 0x9f810000  A15     : 0x003fffff  SAR     : 0x00000015  EXCCAUSE: 0x0000001d
EXCVADDR: 0xdf010000  LBEG    : 0x40104868  LEND    : 0x401048ac  LCOUNT  : 0x0000003c  


Backtrace:0x40091ff5:0x3ffdc7e00x40093e31:0x3ffdc820 0x400940ad:0x3ffdc840 0x4008423a:0x3ffdc860 0x400d38f6:0x3ffdc890 0x400d5fa5:0x3ffdc8b0 0x400d64b0:0x3ffdc950 0x400d6faf:0x3ffdc980 
  #0  0x40091ff5:0x3ffdc7e00 in compare_and_set_native at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_hw_support/include/soc/compare_set.h:25
      (inlined by) spinlock_acquire at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_hw_support/include/soc/spinlock.h:103
      (inlined by) xPortEnterCriticalTimeout at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port/xtensa/port.c:288




ELF file SHA256: 0000000000000000

Rebooting...

Other Steps to Reproduce

Don't know if there is any other way to setup the ethernet.
The version before this, i used other event types like this:

void ethEvent(WiFiEvent_t event){
    if( event == SYSTEM_EVENT_ETH_START ){
        ETH.setHostname(hsh_fileSystem.config.hostname);
    }else if( event == SYSTEM_EVENT_ETH_GOT_IP ){
        Serial.printf("\nConnected to Ethernet\n");
        Serial.printf("NS - IP:\t%s\n",          ETH.localIP().toString().c_str());
        Serial.printf("NS - MAC:\t%s\n",         ETH.macAddress().c_str());
        Serial.printf("NS - Host:\t%s\n",        ETH.getHostname());
    }else if( event == SYSTEM_EVENT_ETH_DISCONNECTED ){
         Serial.println("\nNS - Ethernet disconnected");
    }
}

Worked fine. But these now throws compiler warnings:

src/utilities/networkSystem.cpp: In function 'void ethEvent(arduino_event_id_t)':
src/utilities/networkSystem.cpp:115:18: warning: comparison between 'enum arduino_event_id_t' and 'enum system_event_id_t' [-Wenum-compare]
     if( event == SYSTEM_EVENT_ETH_START ){
                  ^~~~~~~~~~~~~~~~~~~~~~
src/utilities/networkSystem.cpp:117:24: warning: comparison between 'enum arduino_event_id_t' and 'enum system_event_id_t' [-Wenum-compare]
     }else if( event == SYSTEM_EVENT_ETH_GOT_IP ){
                        ^~~~~~~~~~~~~~~~~~~~~~~
src/utilities/networkSystem.cpp:137:24: warning: comparison between 'enum arduino_event_id_t' and 'enum system_event_id_t' [-Wenum-compare]
     }else if( event == SYSTEM_EVENT_ETH_DISCONNECTED ){
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions