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

[TW#25929] ethernet: infinite loop if phy cannot be initialized (IDFGH-1743) #2331

Closed
loboris opened this issue Aug 25, 2018 · 8 comments
Closed

Comments

@loboris
Copy link

loboris commented Aug 25, 2018

Both phy_lan8720_init() and phy_tlk110_init() calls esp_eth_smi_wait_value() in an infinite loop which, in case phy cannot be initialized for some reason, blocks the whole system, eventually causing task watchdog timeout.

I think there should some kind of timeout, the function should exit with failed status which should propagate to esp_eth_enable() function, returning ESP_FAIL.

...
E (784552) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0 (mask 0xfff0). Current value 0xffff
E (785552) emac: Timed out waiting for PHY register 0x2 to have value 0x0007 (mask 0xffff). Current value 0xffff
E (786552) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0 (mask 0xfff0). Current value 0xffff
Task watchdog got triggered. The following tasks did not reset the watchdog in time:
 - mp_task (CPU 1)
Tasks currently running:
CPU 0: IDLE
CPU 1: IDLE
E (787552) emac: Timed out waiting for PHY register 0x2 to have value 0x0007 (mask 0xffff). Current value 0xffff
E (788552) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0 (mask 0xfff0). Current value 0xffff
E (789552) emac: Timed out waiting for PHY register 0x2 to have value 0x0007 (mask 0xffff). Current value 0xffff
...
@negativekelvin
Copy link
Contributor

Linking with #2141

@loboris
Copy link
Author

loboris commented Aug 26, 2018

Thank you for the link, I hope it will be addressed in the esp-idf.

@loboris
Copy link
Author

loboris commented Aug 27, 2018

The issue is slightly different than the linked one as the blocking occurs on different place in code.

It looks like there are infinite loops in the ethernet componnent in several places.
This is realy a bad behaviour, any function should fail gracefully in all possible scenarios instead of blocking (or resetting) the whole system.
The ethernet component developers should realy look at the code and fix this.

@negativekelvin
Copy link
Contributor

Yes I know, just suggesting they should be fixed together. Some of the while loops for the internal Mac registers might be ok although maybe not if something kills the peripheral clock.

@loboris
Copy link
Author

loboris commented Aug 27, 2018

I'm aware that this issue is mainly caused by the hardware issues (in my case it was the bad wiring between ESP32 and the lan8720 module). Nevertheless, it should be handled by the software.

@FayeY FayeY changed the title ethernet: infinite loop if phy cannot be initialized [TW#25929] ethernet: infinite loop if phy cannot be initialized Aug 30, 2018
@gost-serb
Copy link

I also had same situation ones but bug gone after turn off/on power and never happened again

@suda-morris
Copy link
Collaborator

@loboris Thanks for your advice. The infinite loop problem will be fixed in the newest master branch later.

@igrr igrr closed this as completed in 20b7f0e Sep 24, 2018
catalinio pushed a commit to catalinio/pycom-esp-idf that referenced this issue Jun 28, 2019
1. fix infinite loop problem when init phy device
2. fix infinite loop problem when reset mac
3. fix little bugs in ethernetif_init
4. fix incompatible return value between lwip and esp-idf

Closes espressif/esp-idf#2331
Closes espressif/esp-idf#2141
@Mikegyver
Copy link

Mikegyver commented Aug 27, 2019

hi everyone. i'm facing the same issue but with different ethernet shield.

FYI, i'm using ENC28J60 and following are the error appear on arduino serial monitor.

E (1033) emac: Timed out waiting for PHY register 0x2 to have value 0x0007(mask 0xffff). Current value 0x0000
E (2033) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0(mask 0xfff0). Current value 0x0000
E (2033) emac: Initialise PHY device Timeout

i did the test using example code in the library from http://www.fisch.lu/junk/ESP32-Ethernet.zip

hope the details above will provide enough information regarding this issue. regards.

@github-actions github-actions bot changed the title [TW#25929] ethernet: infinite loop if phy cannot be initialized [TW#25929] ethernet: infinite loop if phy cannot be initialized (IDFGH-1743) Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants