← index #16561Issue #15425
Related · high · value 2.689
QUERY · ISSUE

ESP32 + W5500: network.LAN() fails without an interrupt pin

openby YamadaKyoheiopened 2025-01-10updated 2025-11-17
bugport-esp32

Port, board and/or hardware

AtomS3 Lite, Atomic PoE Base (W5500)

MicroPython version

MicroPython v1.24.1 on 2024-11-29; M5Stack AtomS3 Lite with ESP32S3

Reproduction

  1. Connect an AtomS3 Lite to an Atomic PoE Base.
  2. Run the following script:
import machine
import network
spi = machine.SPI(1, sck=machine.Pin(5), mosi=machine.Pin(8), miso=machine.Pin(7))
lan = network.LAN(phy_type=network.PHY_W5500, spi=spi, phy_addr=1, cs=machine.Pin(6))

Expected behaviour

network.LAN() succeeds.

Observed behaviour

network.LAN() fails.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: esp_eth_driver_install failed with invalid argument

Additional Information

Some W5500 modules don’t include an interrupt pin, so ESP-IDF provides a polling mode (commit).
To enable polling, int_gpio_num must be set to -1 and poll_period_ms must be greater than 0.
However, esp_eth_driver_install() fails because poll_period_ms is 0 in ETH_W5500_DEFAULT_CONFIG.
To fix this, we either need to set poll_period_ms to greater than 0 in network_lan.c or change its default in ESP-IDF.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

Micropython allows uninitialised, invalid LAN MAC addresses on network

closedby glenn20opened 2024-07-08updated 2024-08-12
bugport-esp32

Port, board and/or hardware

esp32 port, LILYGO T-ETH-LITE ESP32S3 (W5500 SPI LAN)

MicroPython version

MicroPython v1.23.0 on 2024-06-02; Generic ESP32S3 module with Octal-SPIRAM with ESP32S3

Reproduction

The following code will activate the W5500 interface on the network and initiate a DHCP request with a MAC address of b'\x00\x00\x00\x00\x00\x00'.

import machine, time
from network import LAN, PHY_W5500

spi = machine.SPI(1, sck=10, miso=11, mosi=12)
lan = LAN(0, spi=spi, phy_type=PHY_W5500, phy_addr=1, cs=9, int=13, reset=14)
lan.active(True)

Expected behaviour

lan.active() should fail to activate the interface if the MAC address has not been initialised with lan.config(mac=...) (eg. raise an exception).

Observed behaviour

In general, DHCP servers will refuse the request and lan.isconnected() never returns True (eg. see #15294).

If a static IP address is assigned with lan.ifconfig(), then lan.isconnected() will return True and the device will have full network access, though the device will have an invalid MAC address (which would also conflict with other similarly configured micropython LAN devices on the local network).

Additional Information

This could be addressed by:

  1. adding appropriate documentation reminding users to initialise the MAC address, OR
  2. adding a check in network_lan.c:lan_active() that would raise an exception if the MAC address is uninitialised.

I prefer option 2, as this mitigates the risk of naive use of micropython devices impacting a local network.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied