Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
156adf0
initial commit (it works!!!)
tact1m4n3 Jul 14, 2025
e7c4f76
cleanup examples build script
tact1m4n3 Jul 14, 2025
2e6979e
cleanup
tact1m4n3 Jul 14, 2025
3de76a1
got ip via dhcp
tact1m4n3 Jul 17, 2025
ee50038
cleanup and more
tact1m4n3 Jul 18, 2025
cf54bcf
commit
tact1m4n3 Jul 19, 2025
78da303
more cleanup
tact1m4n3 Jul 21, 2025
49f0e24
undo stack changes
tact1m4n3 Jul 23, 2025
3c41c03
Merge branch 'main' into esp_wifi
tact1m4n3 Nov 23, 2025
287ceeb
Remove pointer from fallback allocator interface
tact1m4n3 Nov 26, 2025
338099b
Improve stability of ESP WiFi (#741)
andreacoradi Nov 27, 2025
9528da2
Progress
tact1m4n3 Dec 9, 2025
9895b3d
Add scheduler and more
tact1m4n3 Dec 27, 2025
c2805f7
Got wifi working and more
tact1m4n3 Dec 28, 2025
d53d261
Completely port osi to new scheduler
tact1m4n3 Dec 28, 2025
2f95908
Fix interrupt nesting
tact1m4n3 Dec 29, 2025
3af9b39
Fix microzig.interrupt.Mutex
tact1m4n3 Dec 29, 2025
48efd95
Fix alignment issues and to small idle stack size
tact1m4n3 Dec 31, 2025
93aeb91
More Scheduler work
tact1m4n3 Jan 2, 2026
88d9e71
Merge branch 'main' into esp_wifi
tact1m4n3 Jan 2, 2026
0cb0872
Fix spawn parameters and update to latest esp wifi
tact1m4n3 Jan 3, 2026
e18e7ae
Refactor and cleanup no. 1
tact1m4n3 Jan 3, 2026
3448341
Refactor scheduler and more
tact1m4n3 Jan 11, 2026
8ec4486
Fix RTOS bug and more
tact1m4n3 Jan 12, 2026
db235ce
Port more changes from esp_wifi
tact1m4n3 Jan 12, 2026
e64cf8c
Refactor wifi and use tcpip for lwip
tact1m4n3 Jan 13, 2026
3b4b9bc
`rtos.Condition`, bigger debug wifi task stack size, blocking start a…
tact1m4n3 Jan 14, 2026
e6fb06d
TCP server example and refactoring
tact1m4n3 Jan 15, 2026
dc52ce1
Cleanup
tact1m4n3 Jan 16, 2026
604f769
Remove SPSC_Queue
tact1m4n3 Jan 16, 2026
f9ecffd
More cleanup
tact1m4n3 Jan 16, 2026
f16c37c
Merge branch 'main' into esp_wifi_reloaded
tact1m4n3 Jan 16, 2026
c44c873
Update network module and fix tbss workaround
tact1m4n3 Jan 16, 2026
9fd611e
Refactor example and fix CI
tact1m4n3 Jan 16, 2026
84a5b4f
Take care of lints
tact1m4n3 Jan 16, 2026
02db8ed
Fix some of the formatting (that does not crash zig)
tact1m4n3 Jan 16, 2026
42c5abd
Hide warnings
tact1m4n3 Jan 16, 2026
21c06be
Cleanup RTOS
tact1m4n3 Jan 17, 2026
0af62f7
Implement mutex priority inheritance
tact1m4n3 Jan 17, 2026
fbb10d1
rtos: Scoped log and log all tasks state fn
tact1m4n3 Jan 17, 2026
bae30a1
Cleanup
tact1m4n3 Jan 17, 2026
ddc69b2
Fix zig fmt crashing
tact1m4n3 Jan 17, 2026
9f217b5
Merge branch 'main' into esp_wifi_reloaded
tact1m4n3 Jan 17, 2026
0e7fb8c
Fix wifi sta config
tact1m4n3 Jan 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/src/interrupt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ pub const CriticalSectionMutex = struct {

/// Unlocks the mutex.
pub fn unlock(self: *CriticalSectionMutex) void {
if (self.critical_section) |cs| {
const maybe_cs = self.critical_section;
self.critical_section = null;
if (maybe_cs) |cs| {
Comment on lines +125 to +127
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug fix

cs.leave();
self.critical_section = null;
}
}
};
178 changes: 169 additions & 9 deletions examples/espressif/esp/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ pub fn build(b: *std.Build) void {
const mz_dep = b.dependency("microzig", .{});
const mb = MicroBuild.init(b, mz_dep) orelse return;

const targets = [_]TargetDescription{
.{ .prefix = "esp32_c3", .target = mb.ports.esp.chips.esp32_c3 },
.{ .prefix = "esp32_c3_direct_boot", .target = mb.ports.esp.chips.esp32_c3_direct_boot },
.{ .prefix = "esp32_c3_flashless", .target = mb.ports.esp.chips.esp32_c3_flashless },
};

const available_examples = [_]Example{
const examples: []const Example = &.{
.{ .name = "blinky", .file = "src/blinky.zig" },
.{ .name = "custom_clock_config", .file = "src/custom_clock_config.zig" },
.{ .name = "gpio_input", .file = "src/gpio_input.zig" },
Expand All @@ -30,15 +24,25 @@ pub fn build(b: *std.Build) void {
.{ .name = "stepper_driver_dumb", .file = "src/stepper_driver_dumb.zig" },
.{ .name = "systimer", .file = "src/systimer.zig" },
.{ .name = "ws2812_blinky", .file = "src/ws2812_blinky.zig" },
.{ .name = "rtos", .file = "src/rtos.zig" },
.{ .name = "tcp_server", .file = "src/tcp_server.zig", .features = .{
.flashless = false,
.lwip = true,
} },
};

for (available_examples) |example| {
for (examples) |example| {
// If we specify example, only select the ones that match
if (maybe_example) |selected_example|
if (!std.mem.containsAtLeast(u8, example.name, 1, selected_example))
continue;

for (targets) |target_desc| {
for (std.enums.values(TargetEnum)) |target_enum| {
if (!example.features.flashless and std.mem.containsAtLeast(u8, @tagName(target_enum), 1, "flashless"))
continue;

const target_desc = target_enum.get_target_desc(mb);

// `add_firmware` basically works like addExecutable, but takes a
// `microzig.Target` for target instead of a `std.zig.CrossTarget`.
//
Expand All @@ -51,6 +55,28 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path(example.file),
});

if (example.features.lwip) {
const target = b.resolveTargetQuery(firmware.target.zig_target);

const foundation_dep = b.dependency("foundation_libc", .{
.target = target,
.optimize = optimize,
.single_threaded = true,
});

const lwip_dep = b.dependency("lwip", .{
.target = target,
.optimize = optimize,
.include_dir = b.path("src/lwip/include"),
});

const libc_lib = foundation_dep.artifact("foundation");
const lwip_lib = lwip_dep.artifact("lwip");

lwip_lib.root_module.linkLibrary(libc_lib);
firmware.app_mod.linkLibrary(lwip_lib);
}

// `installFirmware()` is the MicroZig pendant to `Build.installArtifact()`
// and allows installing the firmware as a typical firmware file.
//
Expand All @@ -63,12 +89,146 @@ pub fn build(b: *std.Build) void {
}
}

const TargetEnum = enum {
esp32_c3,
esp32_c3_direct_boot,
esp32_c3_flashless,

fn get_target_desc(target_enum: TargetEnum, mb: *MicroBuild) TargetDescription {
return switch (target_enum) {
.esp32_c3 => .{
.prefix = "esp32_c3",
.target = mb.ports.esp.chips.esp32_c3,
},
.esp32_c3_direct_boot => .{
.prefix = "esp32_c3_direct_boot",
.target = mb.ports.esp.chips.esp32_c3_direct_boot,
},
.esp32_c3_flashless => .{
.prefix = "esp32_c3_flashless",
.target = mb.ports.esp.chips.esp32_c3_flashless,
},
};
}
};

const TargetDescription = struct {
prefix: []const u8,
target: *const microzig.Target,
};

const Example = struct {
const Features = packed struct {
flashless: bool = true,
lwip: bool = false,
};

name: []const u8,
file: []const u8,
features: Features = .{},
};

const lwip_flags = [_][]const u8{ "-std=c99", "-fno-sanitize=undefined" };
const lwip_files = [_][]const u8{
// Core files
"core/init.c",
"core/def.c",
"core/dns.c",
"core/inet_chksum.c",
"core/ip.c",
"core/mem.c",
"core/memp.c",
"core/netif.c",
"core/pbuf.c",
"core/raw.c",
"core/stats.c",
"core/sys.c",
"core/altcp.c",
"core/altcp_alloc.c",
"core/altcp_tcp.c",
"core/tcp.c",
"core/tcp_in.c",
"core/tcp_out.c",
"core/timeouts.c",
"core/udp.c",

// IPv4 implementation:
"core/ipv4/acd.c",
"core/ipv4/autoip.c",
"core/ipv4/dhcp.c",
"core/ipv4/etharp.c",
"core/ipv4/icmp.c",
"core/ipv4/igmp.c",
"core/ipv4/ip4_frag.c",
"core/ipv4/ip4.c",
"core/ipv4/ip4_addr.c",

// IPv6 implementation:
"core/ipv6/dhcp6.c",
"core/ipv6/ethip6.c",
"core/ipv6/icmp6.c",
"core/ipv6/inet6.c",
"core/ipv6/ip6.c",
"core/ipv6/ip6_addr.c",
"core/ipv6/ip6_frag.c",
"core/ipv6/mld6.c",
"core/ipv6/nd6.c",

// Interfaces
"netif/ethernet.c",

// Interfaces:
// "netif/bridgeif.c",
// "netif/ethernet.c",
// "netif/slipif.c",
// "netif/bridgeif_fdb.c",

// sequential APIs
// "api/err.c",
// "api/api_msg.c",
// "api/netifapi.c",
// "api/sockets.c",
// "api/netbuf.c",
// "api/api_lib.c",
// "api/tcpip.c",
// "api/netdb.c",
// "api/if_api.c",

// 6LoWPAN
// "netif/lowpan6.c",
// "netif/lowpan6_ble.c",
// "netif/lowpan6_common.c",
// "netif/zepif.c",

// PPP
// "netif/ppp/polarssl/arc4.c",
// "netif/ppp/polarssl/des.c",
// "netif/ppp/polarssl/md4.c",
// "netif/ppp/polarssl/sha1.c",
// "netif/ppp/polarssl/md5.c",
// "netif/ppp/ipcp.c",
// "netif/ppp/magic.c",
// "netif/ppp/pppoe.c",
// "netif/ppp/mppe.c",
// "netif/ppp/multilink.c",
// "netif/ppp/chap-new.c",
// "netif/ppp/auth.c",
// "netif/ppp/chap_ms.c",
// "netif/ppp/ipv6cp.c",
// "netif/ppp/chap-md5.c",
// "netif/ppp/upap.c",
// "netif/ppp/pppapi.c",
// "netif/ppp/pppos.c",
// "netif/ppp/eap.c",
// "netif/ppp/pppol2tp.c",
// "netif/ppp/demand.c",
// "netif/ppp/fsm.c",
// "netif/ppp/eui64.c",
// "netif/ppp/ccp.c",
// "netif/ppp/pppcrypt.c",
// "netif/ppp/utils.c",
// "netif/ppp/vj.c",
// "netif/ppp/lcp.c",
// "netif/ppp/ppp.c",
// "netif/ppp/ecp.c",
};
2 changes: 2 additions & 0 deletions examples/espressif/esp/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.version = "0.0.0",
.dependencies = .{
.microzig = .{ .path = "../../.." },
.lwip = .{ .path = "../../../modules/lwip" },
.foundation_libc = .{ .path = "../../../modules/foundation-libc" },
},
.paths = .{
"README.md",
Expand Down
Loading
Loading