You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MicroPython v1.23.0 on 2024-06-02; Arduino Portenta H7 with STM32H747
Reproduction
importnetworkimportsocketimportpyb# Initialize the LAN interface with PHY parameterslan=network.LAN()
lan.config(trace=8, low_power=False)
lan.ifconfig('dhcp')
# Activate the LAN interfacelan.active(True)
print("MAC Address:", lan.config("mac").hex())
# Wait until the link is upwhilenotlan.isconnected():
passprint("Network configuration:", lan.ifconfig())
# Get the IP address of www.google.comtry:
ip_address=socket.getaddrinfo('www.google.com', 80)[0][-1][0]
print("IP address of www.google.com:", ip_address)
exceptExceptionase:
print("Error:", e)
Expected behaviour
We should get the DHCP IP address.
Observed behaviour
15:27:36.010 -> Traceback (most recent call last):
15:27:36.010 -> File "main.py", line 9, in <module>
15:27:36.010 -> OSError: timeout waiting for DHCP to get IP address
15:27:37.495 -> MicroPython v1.23.0 on 2024-06-02; Arduino Portenta H7 with STM32H747
15:27:37.529 -> Type "help()" for more information.
15:27:37.529 -> >>>
Additional Information
I actually tried with setting a static IP instead, like this:
And somehow it gets the DHCP lease successfully, but not using the specified IP.
It also works if I just call: lan.ifconfig()
but it does not work with: lan.ifconfig('dhcp')
15:39:14.146 -> File "main.py", line 8, in <module>
15:39:14.204 -> OSError: timeout waiting for DHCP to get IP address
In OpenMV v4.5.9 this trick does not work, I could not use network.LAN there at all. CC @kwagyeman, not sure what is different, since the MP version is the same 🙁
Can it be because of the MAC address? I see a generic one being assigned (02:37:47:12:32:bb).
This should be in another issue, but it would be nice to be able to set the MAC address:
It's not possible to set a static IP (it gets dhcp instead) and when trying dhcp string as parameter, it throws the timeout error. If you point me into the right file, maybe I can figure it out myself and contribute this back, we are really blocked by this, should it be somewhere here?
@razvanphp - Yeah, it did previously work. Have you reported the issue to Arduino yet? We have a support contract with them to work on this. Once they assign us the work, we can fix it.
Have you reported the issue to Arduino yet? We have a support contract with them to work on this. Once they assign us the work, we can fix it.
Yes, on the forum here and also through contact-us form (request ID is: 304917).
Tried also another older version of OpenMV, same thing:
OpenMV v4.5.2; MicroPython v1.20-omv-r22; PORTENTA-STM32H747
Type "help()" for more information.
>>>
raw REPL; CTRL-B to exit
>OKTraceback (most recent call last):
File "<stdin>", line 9, in <module>
OSError: timeout waiting for DHCP to get IP address
>
OpenMV v4.5.1; MicroPython v1.20-omv-r17; PORTENTA-STM32H747
Type "help()" for more information.
>>>
raw REPL; CTRL-B to exit
>OKTraceback (most recent call last):
File "<stdin>", line 9, in <module>
OSError: timeout waiting for DHCP to get IP address
>
the difference is that now, OpenMV behaves like vanilla micropython, in the sense that it works with (only) DHCP, if passing nothing to lan.ifconfig(), but when passing a tuple for a static IP, it still gets DHCP, so I think this is a bug upstream anyway.
Activity
kwagyeman commentedon Sep 19, 2024
@razvanphp - I can confirm that the latest firmware doesn't work. This is a regression as this worked previously.
Can you let Arduino know about the issue and they will assign us to fix it.
@iabdalkader - For visibility.
razvanphp commentedon Sep 20, 2024
Thanks for the quick answer!
Not sure how/where can I do that.
How else can I help? In which source-code is the most probable place to fix this?
kwagyeman commentedon Sep 20, 2024
Start a thread on their forum:
https://forum.arduino.cc/c/hardware/portenta/pro-family/168
Or email their help support.
kwagyeman commentedon Sep 20, 2024
The issue is likely something buried in MicroPython as the Ethernet is completely controlled by that.
razvanphp commentedon Sep 23, 2024
Not sure if this ever worked, I tried all those firmwares for H7 and all of them fail in the same way:
It's not possible to set a static IP (it gets
dhcpinstead) and when tryingdhcpstring as parameter, it throws the timeout error. If you point me into the right file, maybe I can figure it out myself and contribute this back, we are really blocked by this, should it be somewhere here?micropython/extmod/network_lwip.c
Lines 79 to 84 in 3ca01ec
razvanphp commentedon Sep 23, 2024
BTW, I also tried with:
but still the same behaviour...
I noticed that
ifconfigis deprecated in favour ofipconfig, but those two documentations are not in sync:kwagyeman commentedon Sep 23, 2024
@razvanphp - Yeah, it did previously work. Have you reported the issue to Arduino yet? We have a support contract with them to work on this. Once they assign us the work, we can fix it.
Note, we support the Nicla through our firmware. You should be pulling it from here: https://github.com/openmv/openmv/releases
Try firmware v4.5.2 and older: https://github.com/openmv/openmv/releases/tag/v4.5.2
MicroPython typically gets fixes our firmware receives afterwards as things can take a while to merge upstream.
razvanphp commentedon Sep 24, 2024
Yes, on the forum here and also through contact-us form (request ID is: 304917).
Tried also another older version of OpenMV, same thing:
the difference is that now, OpenMV behaves like vanilla micropython, in the sense that it works with (only) DHCP, if passing nothing to
lan.ifconfig(), but when passing a tuple for a static IP, it still gets DHCP, so I think this is a bug upstream anyway.kwagyeman commentedon Sep 24, 2024
Ah, I never checked this with non dhcp. Yes, probably a big upstream. We don't touch the Ethernet code on the OpenMV Cam.
razvanphp commentedon Sep 28, 2024
Ok, mistery solved!
It seems that the order of
lan.active(True)andlan.ifconfig([tuple])matters, in the sense that calling active resets the interface to DHCP:micropython/ports/stm32/network_lan.c
Lines 73 to 90 in 17d8234
micropython/ports/stm32/eth.c
Lines 852 to 864 in 17d8234
micropython/ports/stm32/eth.c
Lines 777 to 801 in 17d8234
Not sure if adding this to documentation would be beneficial, but this was a waste of time for everybody, I'm sorry for that!
kwagyeman commentedon Oct 2, 2024
@razvanphp - Thanks for debugging this. You should send a documentation update to MicroPython about this for their Ethernet module: https://github.com/micropython/micropython/blob/master/docs/library/network.LAN.rst