Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETH.end() crashes #9655

Closed
1 task done
JAndrassy opened this issue May 19, 2024 · 7 comments · Fixed by #9661
Closed
1 task done

ETH.end() crashes #9655

JAndrassy opened this issue May 19, 2024 · 7 comments · Fixed by #9661
Assignees
Labels
Area: WiFi Issue related to WiFi Status: Awaiting triage Issue is waiting for triage
Milestone

Comments

@JAndrassy
Copy link
Contributor

JAndrassy commented May 19, 2024

Board

ESP32 Dev Module

Device Description

Espressif Dev module

Hardware Configuration

W5500 wired to default SPI pins

Version

latest development Release Candidate (RC-X)

IDE Name

Arduino IDE

Operating System

Linix Mint

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

921600

Description

ETH.end() crashes

Sketch

#define ETH_PHY_TYPE        ETH_PHY_W5500
#define ETH_PHY_ADDR        1
#define ETH_PHY_CS          5
#define ETH_PHY_IRQ         26
#define ETH_PHY_RST         -1
#define ETH_PHY_SPI         SPI

#include <ETH.h>

void setup() {

  Serial.begin(115200);
  delay(500);

  SPI.begin();

  ETH.begin();
  while (!ETH.hasIP()) {
    Serial.print('.');
    delay(1000);
  }

  ETH.end();

  ETH.begin();
  while (!ETH.hasIP()) {
    Serial.print('.');
    delay(1000);
  }
}

void loop() {

}

Debug Message

CORRUPT HEAP: Bad tail at 0x3ffb9a00. Expected 0xbaad5678 got 0x00000000
assert failed: multi_heap_free multi_heap_poisoning.c:276 (head != NULL)

stack trace:

0x400827ad: panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c:466
0x40088709: esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/port/esp_system_chip.c:84
0x4008d99a: __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c:81
0x4008cb25: multi_heap_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c:276 (discriminator 1)
0x40083792: heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:388
0x4008d9d9: free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/heap.c:39
0x4011dddd: post_instance_delete at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_event/esp_event.c:439
 (inlined by) esp_event_loop_run at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_event/esp_event.c:615
0x4011de40: esp_event_loop_run_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_event/esp_event.c:107 (discriminator 15)

Other Steps to Reproduce

WiFi has _esp_netif = NULL; before destroyNetif();. Doing this in ETH.end() avoids the crash, but following ETH.begin() then ends with "E (8710) esp_eth: esp_eth_driver_uninstall(263): 2 ethernet reference in use".

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

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@JAndrassy JAndrassy added the Status: Awaiting triage Issue is waiting for triage label May 19, 2024
@me-no-dev me-no-dev self-assigned this May 19, 2024
@me-no-dev me-no-dev added this to the 3.0.0 milestone May 19, 2024
@sirapol
Copy link

sirapol commented May 20, 2024

@sirapol please do not hijack my issue. your problem is different.

Ok sorry

@VojtechBartoska VojtechBartoska added the Area: WiFi Issue related to WiFi label May 20, 2024
@JAndrassy
Copy link
Contributor Author

JAndrassy commented May 22, 2024

@me-no-dev, it forgets the static IP. I don't know if it should preserve it, since legacy Ethernet API doesn't have config, but WiFi.disconnect() does not erase the static IP configuration here and in other WiFi libraries.
and end() in other Ethernet libraries with 'config` (in esp8266 and RP2040 core) doesn't forget the static IP settings.

EDIT: and now I see that static IP config is not used if I don't have DHCP begin() first. I will add it as issue tomorrow.

@me-no-dev
Copy link
Member

@JAndrassy please open separate issue for that. ETH is different than WiFi, so it might need different approach.

@me-no-dev
Copy link
Member

Also in what case would it make sense to restart the network and keep the same settings, as opposed to just leave it as-is and unplug and plug wherever is necessary

@TD-er
Copy link
Contributor

TD-er commented May 22, 2024

One example when one might want to call ETH.end() and later start over with exactly the same settings:

Ethernet does consume quite a lot of energy.
Typically 50 mA for the Ethernet chip alone and another 50 mA when the link is 'up'.

So it does make sense to power the chip down when it gets unplugged and periodically do a quick check to see if it is plugged in again.

@me-no-dev
Copy link
Member

Because of our network model, implementing this feature will require specific workarounds, that I do not think warrant this 1 in a million use case. You have to be on ETH cable, without PoE or wall power, decide to not just pull RST of ETH and go to deep sleep and also be too bothered to add one line. BTW if you really shut down all WiFi it should also lose the address, because both WiFi netifs will be destroyed. IMHO its not worth it to implement this instead of calling config() after begin()

@TD-er
Copy link
Contributor

TD-er commented May 23, 2024

If you can simply restore it all with a single line of code then I totally agree with not fixing it.

Just for the sake of argument, the use case I mentioned is a real use case where there is a 4g router in the field with an ESP connected to it. If the 4g signal is no longer present, the router is configured to turn off the network LAN ports.
Still this is specific enough to put in some extra effort to make sure the ETH device is configured correctly after the port is 'up' again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: WiFi Issue related to WiFi Status: Awaiting triage Issue is waiting for triage
Projects
Development

Successfully merging a pull request may close this issue.

5 participants