WIRED LAN

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
John12
Posts: 8
Joined: Thu Jun 10, 2021 8:41 pm

WIRED LAN

Post by John12 » Mon Aug 16, 2021 3:16 pm

Hello,

I bought this board to test the wired lan :

www.wireless-tag.com/portfolio/wt32-eth01/

It is a board with esp32 and LAN8720A

I flashed this board with this version of micropython :

esp32-20210816-unstable-v1.16-217-g5b655665a.bin

To test the wired lan, i used the network.LAN class :

Code: Select all

import network
from machine import Pin
lan = network.LAN(mdc=Pin(???), mdio=Pin(???), power=None, id=None, phy_addr=1, phy_type=network.PHY_LAN8720)
QUESTION :
what Pins should i put for "mdc" and "mdio" parameters ?

Thank you for any help

John12
Posts: 8
Joined: Thu Jun 10, 2021 8:41 pm

Re: WIRED LAN

Post by John12 » Mon Aug 16, 2021 3:37 pm

after some searches, i think the answer is :

Code: Select all

mdc = Pin23
mdio = Pin18
...when i tried this code :

Code: Select all

lan = network.LAN(mdc=Pin(23), mdio=Pin(18),power=None, id=None, phy_addr=1,phy_type=network.PHY_LAN8720)
i got these errors :

Code: Select all

E (346651) emac_esp32: emac_esp32_init(308): reset timeout
E (346651) esp_eth: esp_eth_driver_install(198): init mac failed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: esp_eth_driver_install failed
I don't knwo if it could help, but when i tried the same code

Code: Select all

lan = network.LAN(mdc=Pin(23), mdio=Pin(18),power=None, id=None, phy_addr=1,phy_type=network.PHY_LAN8720)
i got new errors

Code: Select all

E (1107051) emac_esp32: esp_eth_mac_new_esp32(453): alloc emac interrupt failed
E (1107051) esp_netif_lwip: esp_netif_new: Failed to configure netif with config=0x3ffcd048 (config or if_key is NULL or duplicate key)
E (1107061) esp_eth.netif.glue: esp-netif handle can't be null
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: esp_eth_set_default_handlers failed (invalid parameter)


What should i do to deal with it?

Thank you for any help

John12
Posts: 8
Joined: Thu Jun 10, 2021 8:41 pm

Re: WIRED LAN

Post by John12 » Mon Aug 16, 2021 6:29 pm

I tried to flash the board with the firmware v1.14 (built with ESP-IDF v3.x), this code :

Code: Select all

lan = network.LAN(mdc=Pin(23), mdio=Pin(18),power=None, id=None, phy_addr=1,phy_type=network.PHY_LAN8720)
worked ! but when triyng to active the network with :

Code: Select all

lan.active(True)
i got these errors :
E (724752) emac: Timed out waiting for PHY register 0x2 to have value 0x0007(mask 0xffff). Current value 0xffff
E (725752) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0(mask 0xfff0). Current value 0xffff
E (725752) emac: Initialise PHY device Timeout
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: ethernet enable failed
Do you have any idea to solve it ?

Thank you

User avatar
WZab
Posts: 25
Joined: Tue Jan 21, 2020 7:45 pm

Re: WIRED LAN

Post by WZab » Sat Aug 21, 2021 4:26 pm

What works for me is:

Code: Select all

import network
import machine as m
nl=network.LAN(mdc=m.Pin(23),mdio=m.Pin(18),power=m.Pin(16),id=0,phy_addr=1,phy_type=network.PHY_LAN8720)
nl.active(1)
After that, the board gets it's address via DHCP and I can check it with:

Code: Select all

>>> nl.ifconfig()
('192.168.33.244', '255.255.255.0', '192.168.33.1', '192.168.33.1')
I have flashed my board with:

Code: Select all

esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20210623-v1.16.bin

aleskeyfedorovich
Posts: 28
Joined: Mon Aug 27, 2018 4:43 pm

Re: WIRED LAN

Post by aleskeyfedorovich » Thu Nov 25, 2021 9:47 am

I found no documentation for the network.LAN class.
From which micropython version was it implemented in the firmware?
Is there any documentation on how to use it?

Post Reply