Skip to content

ETH_PHY_POWER set as output after ETH.begin() causes board to restart on 3.0.0-alpha3 #9429

@Stanimir-Petev

Description

@Stanimir-Petev

Board

Olimex ESP32-POE

Device Description

The board is connected to the computer with USB-micro cable to power the board and for monitoring. Ethernet cable connects the board to the local network.

Hardware Configuration

GPIO 34 is attached to a button with active (pressed) state 0.

Version

latest development Release Candidate (RC-X)

IDE Name

Arduino 1.8.19

Operating System

Windows 10

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

115200

Description

Hello!

I am an Olimex employee and recently found a strange issue with the pin of the Ethernet phy power with the latest version (at the moment of posting this issue 3.0.0-alpha3).

I was experimenting something related to an issue report from our customer and I wanted to try resetting the phy by disabling and then reenabling the power of the phy (using the phy power pin). And for my surprise the board reset right after the pin is set as output if the ethernet has already been initialized (check the sketch I am posting with this issue).
If the pin is initialized as output BEFORE the ETH.begin() call then the board doesn't reset but the pin level can't be manipulated to low and high level. Basically not behaving as an output at all.

I decided to try it with the older 2.0.14 version. Not only that it didn't reset but it worked as I expected - when the phy is high the ethernet is working (successfully pinged the given IP) and when it's low it isn't working (ping timeouts).

I tried to simplify to sketch as much as I can to get as close as possible to the problem. But from what I have seen I guess it is something related to the latest changes of the ethernet library and the way the pins are defined. Could be wrong though.

Sketch

#ifndef ETH_PHY_TYPE
  #define ETH_PHY_TYPE        ETH_PHY_LAN8720
  #define ETH_PHY_ADDR         0
  #define ETH_PHY_MDC         23
  #define ETH_PHY_MDIO        18
  #define ETH_PHY_POWER       12
  #if defined BOARD_HAS_PSRAM  // when PSRAM is enabled pins 16 and 17 are used for the PSRAM and alternative pins are used for respectively I2C SCL and Ethernet Clock GPIO
  #define ETH_CLK_MODE        ETH_CLOCK_GPIO0_OUT
  #else
  #define ETH_CLK_MODE        ETH_CLOCK_GPIO17_OUT
  #endif
#endif

#include <ETH.h>
#define BUTTON 34

void setup()
{
  Serial.begin(115200);
  pinMode (BUTTON, INPUT);
  
  ETH.begin();
  while (!(unsigned int)ETH.localIP());
  Serial.print ("\n\rEthernet IP address: ");
  Serial.println (ETH.localIP());
  Serial.printf ("Ethernet PHY configuration:\n\r  ETH_PHY_TYPE = %d\n\r  ETH_PHY_ADDR = %d\n\r  ETH_PHY_MDC = %d\n\r  ETH_PHY_MDIO = %d\n\r  ETH_PHY_POWER = %d\n\r  ETH_CLK_MODE = %d\n\r",
  ETH_PHY_TYPE, ETH_PHY_ADDR, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_POWER, ETH_CLK_MODE);
  
  pinMode (ETH_PHY_POWER, OUTPUT);
}

void loop()
{
  if (!digitalRead(BUTTON))
  {
    digitalWrite (ETH_PHY_POWER, !digitalRead(ETH_PHY_POWER));
    Serial.printf ("Eth phy power %d\n\r", digitalRead(ETH_PHY_POWER));
    while (!digitalRead(BUTTON));
  }
}

Debug Message

Output with 3.0.0-alpha3:

10:43:19.368 -> Ethernet IP address: 192.168.0.183
10:43:19.368 -> Ethernet PHY configuration:
10:43:19.368 ->   ETH_PHY_TYPE = 0
10:43:19.368 ->   ETH_PHY_ADDR = 0
10:43:19.368 ->   ETH_PHY_MDC = 23
10:43:19.368 ->   ETH_PHY_MDIO = 18
10:43:19.368 ->   ETH_PHY_POWER = 12
10:43:19.368 ->   ETH_CLK_MODE = 3
10:43:19.368 -> Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
10:43:19.368 -> 
10:43:19.368 -> Core  0 register dump:
10:43:19.368 -> PC      : 0x400f008d  PS      : 0x00060530  A0      : 0x800f0273  A1      : 0x3ffb9740  
10:43:19.415 -> A2      : 0xd7eafe67  A3      : 0x00000005  A4      : 0x00000000  A5      : 0x3ffb2e90  
10:43:19.415 -> A6      : 0x00000005  A7      : 0x00000001  A8      : 0x00000002  A9      : 0x3ffb9720  
10:43:19.415 -> A10     : 0x00000002  A11     : 0x400f4c00  A12     : 0x00000000  A13     : 0x00000000  
10:43:19.415 -> A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000019  EXCCAUSE: 0x0000001c  
10:43:19.415 -> EXCVADDR: 0xd7eafe80  LBEG    : 0x400894bc  LEND    : 0x400894d2  LCOUNT  : 0xffffffff  
10:43:19.415 -> 
10:43:19.415 -> 
10:43:19.415 -> Backtrace: 0x400f008a:0x3ffb9740 0x400f0270:0x3ffb9760 0x400e5a96:0x3ffb9780 0x400e6435:0x3ffb97a0 0x400e6495:0x3ffb9820 0x400f52ca:0x3ffb9840 0x400f4c0e:0x3ffb9860 0x400e5616:0x3ffb9880
10:43:19.463 -> 
10:43:19.463 -> 
10:43:19.463 -> 
10:43:19.463 -> 
10:43:19.463 -> ELF file SHA256: a2ae87b53011ae87
10:43:19.463 -> 
10:43:19.463 -> Rebooting...
10:43:19.463 -> ets Jun  8 2016 00:22:57
10:43:19.463 -> 
10:43:19.463 -> rst:0xc (SW_CPU_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
10:43:19.463 -> configsip: 0, SPIWP:0xee
10:43:19.463 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:43:19.463 -> mode:DIO, clock div:1
10:43:19.463 -> load:0x3fff0030,len:1256
10:43:19.463 -> load:0x40078000,len:13832
10:43:19.463 -> load:0x40080400,len:4
10:43:19.463 -> load:0x40080404,len:3048
10:43:19.463 -> entry 0x40080590





Output with 2.0.14 (and when I press the button few times to disable/enable phy power pin):

10:26:59.181 -> Ethernet IP address: 192.168.0.201
10:26:59.181 -> Ethernet PHY configuration:
10:26:59.181 ->   ETH_PHY_TYPE = 0
10:26:59.181 ->   ETH_PHY_ADDR = 0
10:26:59.181 ->   ETH_PHY_MDC = 23
10:26:59.181 ->   ETH_PHY_MDIO = 18
10:26:59.181 ->   ETH_PHY_POWER = 12
10:26:59.181 ->   ETH_CLK_MODE = 3
10:26:59.181 -> Eth phy power 0            --> ping request timed out or destination host unreachable
10:27:02.696 -> Eth phy power 1            --> receiving reply from the ping
10:27:09.212 -> Eth phy power 0            --> ping request timed out or destination host unreachable
10:27:18.868 -> Eth phy power 1            --> receiving reply from the ping
10:27:19.148 -> Eth phy power 0            --> ping request timed out or destination host unreachable
10:27:19.148 -> Eth phy power 1            --> receiving reply from the ping

Other Steps to Reproduce

No response

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

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions