Open progerstar opened 10 months ago
Confirmed. Did you look into the code to find the root cause?
For a possible quick-fix I added esp_eth_deinit()
at the end of function eth_stop but the root-cause seems to be the lan8720 chip not being properly re-initialized:
/ > net.en.setup()
/ > net.en.start(false)
/ > net.stat()
wf: mac address 00:00:00:00:00:00
ip address 0.0.0.0 / netmask 0.0.0.0
gw address 0.0.0.0
en: mac address 94:b9:7e:d3:f3:5b
ip address 192.168.1.122 netmask 255.255.255.0
gw address 192.168.1.200
ns:
dns-server 1 ip address 192.168.1.200
dns-server 2 is unset
dns-server 3 is unset
/ > net.en.stop()
/ > net.en.setup()
/ > net.en.start(false)
E (32230) emac: Timed out waiting for PHY register 0x2 to have value 0x0007(mask 0xffff). Current value 0x0000
E (33231) emac: Timed out waiting for PHY register 0x3 to have value 0xc111(mask 0xfff0). Current value 0x0000
E (34238) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0(mask 0xfff0). Current value 0x0000
E (34239) emac: Initialise PHY device Timeout
stdin:1: 503316483:can't connect check cable
stack traceback:
[C]: in field 'start'
stdin:1: in main chunk
[C]: in ?
Yep, net.en.setup() doesn't run twise, because status_get(STATUS_ETH_SETUP) still true after deinit. The fix is an additional command status_set(0x00000000, STATUS_ETH_SETUP) in a *eth_stop().
Sure that's really enough? I think I had tested that before and it wasn't sufficient.
Yes, there is no way to avoid the following code from the net.en.setup() otherwise:
if (!status_get(STATUS_ETH_SETUP)) { if ((error = net_init())) { return error; } status_set(STATUS_ETH_SETUP, 0x00000000); } else { return NULL; }
I've tried with CONFIG_PHY_POWER_PIN (i.e. with hw ic reset) and without it.
Network driver (tested on lan8720) works only once. 2 different scenarios:
1. DHCP after DHCP
/ > net.en.setup() / > net.en.start(false) [..IP is ok..] / > net.en.stop() / > net.en.setup() / > net.en.start(false) stdin:1: 503316483:can't connect check cable stack traceback: [C]: in field 'start' stdin:1: in main chunk [C]: in ?
2. Static IP if DHCP failed
/ > net.en.setup() [..DHCP server is unpulgged..] / > net.en.start(false) stdin:1: 503316483:can't connect check cable stack traceback: [C]: in field 'start' stdin:1: in main chunk [C]: in ? / > net.en.setup( net.packip(192,168,1,200), net.packip(255,255,255,0), net.packip(192,168,1,1), net.packip(8,8,8,8), net.packip(8,8,4,4) ) / > net.en.start(false) / > net.stat() ... ip address 0.0.0.0 netmask 0.0.0.0 gw address 0.0.0.0