Skip to content

Crash using with ESP32_ETH #15

@zekageri

Description

@zekageri

Hi! Thank you for the implementation. It sure looks really promising. I'm trying to initiate a basic communication between esp32 and an android apk for now.

I'm using ETH implementation by espressif with lan8720 eth board.

A snippet from my sketch:

void ethEvent(WiFiEvent_t event){
    if( event == SYSTEM_EVENT_ETH_START ){
        ETH.setHostname(config.hostname);
    }else if( event == SYSTEM_EVENT_ETH_GOT_IP ){
        gotIp_MS    = millis();
        gotIP       = true;
        canWireGuardBegin = true;
    }else if( event == SYSTEM_EVENT_ETH_DISCONNECTED ){
        gotIp_MS    = 0;
        gotIP       = false;
    }
}

inline void startEthernet(){
    Serial.println("Starting ethernet...");
    ETH.begin(
        ETH_PHY_ADDR,
        PIN_PHY_POWER,
        PIN_SMI_MDC,
        PIN_SMI_MDIO,
        ETH_PHY_LAN8720,
        ETH_CLK_MODE
    );
    if( !config.dhcpIsOn )
        {ETH.config(config.ip, config.gw, config.sub, config.dns1, config.dns2);}
    WiFi.onEvent(ethEvent);
}

void setup(){
    startEthernet();
}

static WireGuard wg;
long lastWgPacket = 0;
boolean canWireGuardBegin   = false;
boolean isWgConfigured      = false;

static const inline void beginWireGuard(){
    if(canWireGuardBegin){
        canWireGuardBegin = false;
        configTime(9 * 60 * 60, 0, "ntp.jst.mfeed.ad.jp", "ntp.nict.jp", "time.google.com");
        isWgConfigured = wg.begin(
            local_ip,           // IP address of the local interface
            private_key,        // Private key of the local interface
            endpoint_address,   // Address of the endpoint peer.
            public_key,         // Public key of the endpoint peer.
            endpoint_port);     // Port pf the endpoint peer.

        Serial.println("isWgConfigured: " + String(isWgConfigured));
        // Sketch is crashing right here, printing: isWgConfigured: 1
    }
}

void loop(){
    beginWireGuard();
}

Crash LOG:

isWgConfigured: 1
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x40157cf9  PS      : 0x00060730  A0      : 0x80157f64  A1      : 0x3ffce510  
A2      : 0x3ffe753c  A3      : 0x3ffe7b70  A4      : 0x3ffe7670  A5      : 0x00000000
A6      : 0x0000002e  A7      : 0x00000004  A8      : 0x00000000  A9      : 0x3ffe7b73  
A10     : 0x3ffe7b70  A11     : 0x40089960  A12     : 0x3ffce5fc  A13     : 0x0000003f
A14     : 0x00002033  A15     : 0x00000091  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000014  LBEG    : 0x4008c8c8  LEND    : 0x4008c8e4  LCOUNT  : 0x00000000

ELF file SHA256: 0000000000000000

Backtrace: 0x40157cf9:0x3ffce510 0x40157f61:0x3ffce550 0x40104da7:0x3ffce570 0x40154fa9:0x3ffce640 
0x401551b0:0x3ffce660 0x40161320:0x3ffce680 0x4009070a:0x3ffce6b0
  #0  0x40157cf9:0x3ffce510 in udp_sendto_if_src at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/udp.c:720 (discriminator 2)
  #1  0x40157f61:0x3ffce550 in udp_sendto_if at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/udp.c:689
  #2  0x40104da7:0x3ffce570 in wireguardif_peer_output at lib\WireGuard-ESP32-Arduino-main\src/wireguardif.c:912
      (inlined by) wireguard_start_handshake at lib\WireGuard-ESP32-Arduino-main\src/wireguardif.c:635
      (inlined by) wireguardif_tmr at lib\WireGuard-ESP32-Arduino-main\src/wireguardif.c:882       
  #3  0x40154fa9:0x3ffce640 in sys_check_timeouts at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/timeouts.c:381
  #4  0x401551b0:0x3ffce660 in sys_timeouts_mbox_fetch at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/timeouts.c:433
  #5  0x40161320:0x3ffce680 in tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:483
  #6  0x4009070a:0x3ffce6b0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

Rebooting...

All other standard ethernet communication is working. I have an Async webserver and i can do http requests, websockets and everything else.

  • PlatformIO
  • ESP32-Wrover-E (16mb)
  • Arduino

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions