extract network module from pico WiFi examples#846
Merged
mattnite merged 8 commits intoZigEmbeddedGroup:mainfrom Jan 15, 2026
Merged
extract network module from pico WiFi examples#846mattnite merged 8 commits intoZigEmbeddedGroup:mainfrom
mattnite merged 8 commits intoZigEmbeddedGroup:mainfrom
Conversation
There was a problem hiding this comment.
🔍 Lint Results
Found 1 issue on changed lines in 1 file:
- modules/network/src/root.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 14 issue(s) exist but are not on lines changed in this PR:
port/raspberrypi/rp2xxx/src/hal/drivers.zig:478: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:13: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:14: Suggestion: Rename `Stream_Device` to `StreamDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:16: Suggestion: Rename `Clock_Device` to `ClockDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:17: Suggestion: Rename `I2CError` to `I2C_Error`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:18: Suggestion: Rename `I2CAddress` to `I2C_Address`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:23: Suggestion: Rename `I2C_Datagram_Device` to `I2C_DatagramDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:468: Suggestion: Rename `Cyw43PioSpi` to `CYW43_PIO_SPI`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:469: Suggestion: Rename `Cyw43_Spi` to `CYW43_SPI`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:470: Suggestion: Rename `Cyw43_Bus` to `CYW43_Bus`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:471: Suggestion: Rename `Cyw43_Runner` to `CYW43_Runner`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:473: Suggestion: Rename `CYW43_Pio_Device_Config` to `CYW43_PIO_DeviceConfig`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:479: Suggestion: Rename `CYW43_Pio_Device` to `CYW43_PIO_Device`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:517: Suggestion: Rename `Spi` to `SPI`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
Updating with new lint results
There was a problem hiding this comment.
🔍 Lint Results
ℹ️ Additional issues on unchanged lines
The following 15 issue(s) exist but are not on lines changed in this PR:
drivers/wireless/cyw43439/wifi.zig:103: Suggestion: Rename `ClmLoadControl` to `CLM_LoadControl`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:478: TODO style comments need to have a linked microzig issue on the same line.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:13: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:14: Suggestion: Rename `Stream_Device` to `StreamDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:16: Suggestion: Rename `Clock_Device` to `ClockDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:17: Suggestion: Rename `I2CError` to `I2C_Error`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:18: Suggestion: Rename `I2CAddress` to `I2C_Address`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:23: Suggestion: Rename `I2C_Datagram_Device` to `I2C_DatagramDevice`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:468: Suggestion: Rename `Cyw43PioSpi` to `CYW43_PIO_SPI`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:469: Suggestion: Rename `Cyw43_Spi` to `CYW43_SPI`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:470: Suggestion: Rename `Cyw43_Bus` to `CYW43_Bus`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:471: Suggestion: Rename `Cyw43_Runner` to `CYW43_Runner`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:473: Suggestion: Rename `CYW43_Pio_Device_Config` to `CYW43_PIO_DeviceConfig`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:479: Suggestion: Rename `CYW43_Pio_Device` to `CYW43_PIO_Device`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
port/raspberrypi/rp2xxx/src/hal/drivers.zig:517: Suggestion: Rename `Spi` to `SPI`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.
Grazfather
reviewed
Jan 14, 2026
Grazfather
reviewed
Jan 14, 2026
tact1m4n3
reviewed
Jan 15, 2026
tact1m4n3
reviewed
Jan 15, 2026
Integrating lwip requires adding foundationlibc and lwip dependencies.
Putting lwipopts.h and arch/cc.h to the include path, setting
options and implementing some functions required by lwip.
To simplify that I extracted everything that is not dependent on the
platform into network module. That simplifies using it in applications
outside of the rpi/examples/net folder. And opens the path to use lwip
on other platforms.
Using WiFi in rpi pico (2)w projects is now simplified to adding dependency to the `build.zig.zon`:
```zig
.dependencies = .{
.microzig = .{
.path = "../../microzig/",
},
.net = .{
.path = "../../microzig/modules/network/",
},
},
```
and adding module to the application in `build.zig`:
```zig
const std = @import("std");
const microzig = @import("microzig");
const MicroBuild = microzig.MicroBuild(.{
.rp2xxx = true,
});
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const mz_dep = b.dependency("microzig", .{});
const mb = MicroBuild.init(b, mz_dep) orelse return;
const target = mb.ports.rp2xxx.boards.raspberrypi.pico2_arm;
const net_dep = b.dependency("net", .{
.target = b.resolveTargetQuery(target.zig_target),
.optimize = optimize,
.lwip_mem_size = 32 * 1024,
.lwip_pbuf_pool_size = 32,
});
const net_mod = net_dep.module("net");
const firmware = mb.add_firmware(.{
.name = app,
.target = target,
.optimize = optimize,
.root_source_file = b.path("src/main.zig"),
.imports = &.{
.{ .name = "net", .module = net_mod },
},
});
mb.install_firmware(firmware, .{});
}
```
Lwip has a lot of configurable options. Currently in the build system I
opened two of them for configuration: `lwip_mem_size` and
`lwip_pbuf_pool_size`. That controls memory allocations; static packet
buffers pool size and maximum of heap allocation.
There are two platform dependent functions required by lwip:
`lwip_sys_now` and `lwip_rand`. For rpi they are implemented in `hal/drivers.zig`.
Previous one was IP4 specific.
net.Interface depends on underlying link implementation. They are in different projects so we can't share some struct definition without including whole module. This adapts one interface to another. Also removing ready function. If chip can't store network packet it is now signaled with error.OutOfMemory.
Move cyw43 specific options to the rpi pico examples build.
Drivers project now imports that interface.
mattnite
approved these changes
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrating lwip requires adding foundationlibc and lwip dependencies. Putting lwipopts.h and arch/cc.h to the include path, setting options and implementing some functions required by lwip.
To simplify that I extracted everything that is not dependent on the platform into network module. That simplifies using it in applications outside of the rpi/examples/net folder. And opens the path to use lwip on other platforms.
Using WiFi in rpi pico (2)w projects is now simplified to adding dependency to the
build.zig.zon:and adding module to the application in
build.zig:Lwip has a lot of configurable options. Currently in the build system I opened two of them for configuration:
lwip_mem_sizeandlwip_pbuf_pool_size. That controls memory allocations; static packet buffers pool size and maximum of heap allocation.There are two platform dependent functions required by lwip:
lwip_sys_nowandlwip_rand. For rpi they are implemented inhal/drivers.zig.