← index #3683PR #15676
Related · high · value 2.660
QUERY · ISSUE

IPv6 Support in micropython for ESP32 (or anything for that matter)

openby owendelongopened 2018-03-26updated 2026-01-25
port-esp32

It looks like LWIP in the ESP-IDF being used for micropython has IPv6 support.

Is there an effort to take advantage of the yet? I found some documentation which stated that IPv6 support was "port" dependent, but I have yet to find any port of micropython with IPv6 support enabled.

It looks like the current build has IPv6 capabilities in the usocket module, but it looks like there are no IPv6 capabilities in the network or WLAN class implementations which means that the interface can't get an IPv6 address, etc.

I'm willing to put some effort into trying to do the needful, but the existing API seems to be so thoroughly incapable of understanding that there could possibly be any protocol other than IPv4 that I'm unsure how to go about providing a mergeable codebase that wouldn't break people's existing code.

Further, I'd like to know if there are any standard APIs for IPv6 interface configuration that I should be following as the existing interface configuration capabilities in the ESP32 port are quite thoroughly incapable of such.

Any pointers (or ideally a solution already developed) greatly appreciated.

CANDIDATE · PULL REQUEST

wiznet5k: Add support for IPv6.

mergedby greezybaconopened 2024-08-18updated 2024-08-26
extmod

<!-- Thanks for submitting a Pull Request! We appreciate you spending the
time to improve MicroPython. Please provide enough information so that
others can review your Pull Request.

 Before submitting, please read:
 https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md
 https://github.com/micropython/micropython/wiki/ContributorGuidelines

 Please check any CI failures that appear after your Pull Request is opened.

-->

Summary

This adds support for the WIZNET5K nic to use IPv6 with the LWIP stack. Additionally, if LWIP_IPV6 is disabled, the device is configured to drop all IPv6 packets to reduce load on the MCU.

Changes borrowed in spirit from the LWIP "Mainloop mode ("NO_SYS")" page, https://www.nongnu.org/lwip/2_0_x/group__lwip__nosys.html

<!-- Explain the reason for making this change. What problem does the pull request
solve, or what improvement does it add? Add links if relevant. -->

Testing

<!-- Explain what testing you did, and on which boards/ports. If there are
boards or ports that you couldn't test, please mention this here as well.

 If you leave this empty then your Pull Request may be closed. -->

Testing was performed on the RP2040 with the Wiznet W5500 chip.

  • IPv4 address via dhcp4
  • IPv6 address via autoconf6
  • TCP network service via IPv4 any address ('0.0.0.0')
    • Was able to connect via both IPv4 and IPv6 address
  • TCP network service via IPv6 any address ('::')
    • Was able to connect via both IPv4 and IPv6 address
  • PING to both the IPv4 and IPv6 addresses
  • PING to the IPv6 link-local address

What seems not to work

  • DHCPv6 (I use a delegated IPv6 prefix). LWIP is not able to retrieve an address over DHCPv6. Tested with
>>> nic = network.WIZNET5K()
>>> nic.active(True)
>>> nic.ipconfig(dhcp6=True)
>>> # Wait 30 seconds
>>> nic.ipconfig('addr6')
[('FE80::D2:CBFF:FE6D:6192', 48, 0, 0)]

I suspect this is a pre-existing issue with the ipconfig function and LWIP.

Trade-offs and Alternatives

<!-- If the Pull Request has some negative impact (i.e. increased code size)
then please explain why you think the trade-off improvement is worth it.
If you can think of alternative ways to do this, please explain that here too.

 Delete this heading if not relevant (i.e. small fixes) -->

Positively, the device will discard all IPv6 packets if IPv6 support is disabled in the firmware.

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