Skip to content

Zephyr: Add network module with WLAN/LAN configuration support. - #18205

Draft
bikeNomad wants to merge 1 commit into
micropython:masterfrom
bikeNomad:zephyr/add-network-module
Draft

Zephyr: Add network module with WLAN/LAN configuration support.#18205
bikeNomad wants to merge 1 commit into
micropython:masterfrom
bikeNomad:zephyr/add-network-module

Conversation

@bikeNomad

Copy link
Copy Markdown
Contributor

Summary

This PR adds a new network module providing standard MicroPython network API for configuring WiFi and Ethernet interfaces on Zephyr RTOS. This enables interface activation, connection management, and IP configuration.

Although there was a socket module, it was impossible to use sockets in a real board because of the lack of a network module allowing control of Ethernet and Wifi hardware.

Features:

  • network.WLAN class for WiFi configuration (connect, disconnect, status)
  • network.LAN class for Ethernet configuration
  • ifconfig() method returns IP, netmask, gateway, and DNS server
  • Event-driven connection status tracking via Zephyr net_mgmt
  • DHCP support with fallback DNS configuration

Files modified:

  • ports/zephyr/modnetwork.c (new)
  • ports/zephyr/modsocket.c (major refactoring)
  • ports/zephyr/mpconfigport.h
  • ports/zephyr/CMakeLists.txt
  • ports/zephyr/main.c
  • ports/zephyr/prj.conf

Testing

I've tested this on my MIMXRT1020_EVK board using its Ethernet interface. I haven't had a chance to make a board configuration for a wifi-enabled board yet (I have Rpi Pico W boards available).

Trade-offs and Alternatives

This PR (on the MIMXRT1020_EVK, with -Og optimization) adds:

  • 1968 bytes of flash
  • 128 bytes of RAM

Add new network module providing standard MicroPython network API for
configuring WiFi and Ethernet interfaces on Zephyr RTOS. This enables
interface activation, connection management, and IP configuration.

Features:
- network.WLAN class for WiFi configuration (connect, disconnect, status)
- network.LAN class for Ethernet configuration
- ifconfig() method returns IP, netmask, gateway, and DNS server
- Event-driven connection status tracking via Zephyr net_mgmt
- DHCP support with fallback DNS configuration

Files modified:
- ports/zephyr/modnetwork.c (new)
- ports/zephyr/modsocket.c (major refactoring)
- ports/zephyr/mpconfigport.h
- ports/zephyr/CMakeLists.txt
- ports/zephyr/main.c
- ports/zephyr/prj.conf

🤖 Generated with the help of [Claude Code](https://claude.com/claude-code)

Signed-off-by: Ned Konz <ned@metamagix.tech>
@bikeNomad
bikeNomad force-pushed the zephyr/add-network-module branch from f5b5121 to 0fd2264 Compare October 4, 2025 02:58
@bikeNomad
bikeNomad marked this pull request as draft October 7, 2025 23:09
@bikeNomad

Copy link
Copy Markdown
Contributor Author

I'm still working on getting this complete and passing the tests.

@dpgeorge

dpgeorge commented Oct 7, 2025

Copy link
Copy Markdown
Member

This is great! But please make sure it matches the existing API, in particular:

  • it should use extmod/modnetwork.c as the skeleton implementation of the network module
  • ifconfig() is deprecated in favour of ipconfig()

@VynDragon

Copy link
Copy Markdown
Contributor

Hello, what is the status of this? I am looking at implementing WLAN for Bouffalolab boards

@bikeNomad

Copy link
Copy Markdown
Contributor Author

@VynDragon I haven't had a chance to work on it any more since then; sorry.

@VynDragon

Copy link
Copy Markdown
Contributor

Alright, I'll try coming up with something for WLAN

@VynDragon

Copy link
Copy Markdown
Contributor

@bikeNomad #19666 Check this out, would appreciate if you tested and extended it with LAN support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants