Unable to setup IP with nic.ipconfig() while works with obsolete nic.ifconfig() network.WIZNET5K
Port, board and/or hardware
RPi Pico, W5500-EVB-Pico
MicroPython version
MicroPython v1.24.1 on 2024-11-29; W5500-EVB-Pico with RP2040
Reproduction
Run below code with
# nic.ipconfig(addr4="192.168.9.12/24",gw4="192.168.9.3") # No pings reply
nor
# nic.ipconfig(addr4=("192.168.9.12","255.255.255.0"),gw4="192.168.9.3") # No ping reply
import network
import time
nic = network.WIZNET5K()
print (nic)
nic.active(True)
print (f"Activated {nic=}")
# nic.ifconfig(('192.168.9.12', '255.255.255.0', '192.168.9.3', '192.168.9.3')) # Pings OK
nic.ipconfig(addr4="192.168.9.12/24",gw4="192.168.9.3") # No pings reply
# nic.ipconfig(addr4=("192.168.9.12","255.255.255.0"),gw4="192.168.9.3") # No ping reply
network.ipconfig(dns="192.168.9.3", prefer=4)
print(f'After static nic config {nic=} {nic.ifconfig()=}')
print(f'After static network config {network.ipconfig("dns")=} {network.ipconfig("prefer")=}')
# In all three cases prints same:
# After static nic config nic=<WIZNET5K> nic.ifconfig()=('192.168.9.12', '255.255.255.0', '192.168.9.3', '192.168.9.3')
# After static network config network.ipconfig("dns")=192.168.9.3 network.ipconfig("prefer")=4
# nic.connect() AttributeError: 'WIZNET5K' object has no attribute 'connect'
print("Waiting for connection...")
while not nic.isconnected():
print ("Not connected")
time.sleep(1)
print ("Connected")
while 1:
time.sleep(3)
print (f"{nic.isconnected()=}")
Expected behaviour
Reply to ICMP ping when NIC configured with nic.ipconfig()
Observed behaviour
No reply to ICMP Ping when configured with nic.ipconfig()
But ICMP Ping replies received after init via nic.ifconfig().
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
Stm32f767 Ethernet cannot work without DHCP server.
When Ethernet is directly connected to f767 and PC, the IP address cannot be obtained. At this time, after manually configuring the IP address, the MPY status is 3, ifconfig displays the configured static IP address ,but the Ping operation cannot be completed.
If static IP is not configured, the state remains at 2
If you connect through a router, can automatically obtain the IP address, and then configure the static IP to work normally
It is recommended to modify the configuration to static IP and use it directly instead of DHCP
import network,time
nic=network.LAN()
nic.active(True)
print("starting ethernet ",end="")
while(nic.isconnected()==False):
time.sleep(0.5)
print(nic.status())
#nic.ifconfig(("192.168.99.105", "255.255.255.0", "192.168.99.1", "8.8.8.8"))
nic.ifconfig(("192.168.99.105", "255.255.255.0", "192.168.99.1", "8.8.8.8"))
print("ok!")
#check ip numbers etc.
print(nic.ifconfig())