Skip to content

Conversation

@tact1m4n3
Copy link
Collaborator

No description provided.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🔍 Lint Results

Found 9 issues on changed lines in 9 files:

  • examples/espressif/esp/src/tcp_server.zig: 1 issue
  • examples/raspberrypi/rp2xxx/src/net/lwip/net.zig: 1 issue
  • port/espressif/esp/src/hal/radio/osi.zig: 1 issue
  • port/espressif/esp/src/hal/system.zig: 1 issue
  • port/raspberrypi/rp2xxx/src/hal/usb.zig: 1 issue
  • port/stmicro/stm32/src/hals/STM32F103/adc.zig: 1 issue
  • port/stmicro/stm32/src/hals/STM32F103/i2c.zig: 1 issue
  • port/stmicro/stm32/src/hals/STM32F103/rcc.zig: 1 issue
  • port/stmicro/stm32/src/hals/common/i2c_v2.zig: 1 issue

⚠️ Could not attach inline comments due to an error.

Comment on lines +125 to +127
const maybe_cs = self.critical_section;
self.critical_section = null;
if (maybe_cs) |cs| {
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

var ip_ready_semaphore: rtos.Semaphore = .init(0, 1);
var ip: lwip.c.ip_addr_t = undefined;

extern fn netconn_new_with_proto_and_callback(t: lwip.c.enum_netconn_type, proto: lwip.c.u8_t, callback: ?*const anyopaque) [*c]lwip.c.struct_netconn;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

translate c output for lwip has some issues

}
};

pub fn expect_handler(comptime int: Interrupt, comptime expected_handler: InterruptHandler) void {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an interesting pattern to use in other hals as well

Comment on lines +168 to +182
@export(&strlen, .{ .name = "strlen", .linkage = .weak });
@export(&strnlen, .{ .name = "strnlen", .linkage = .weak });
@export(&strrchr, .{ .name = "strrchr", .linkage = .weak });

@export(&__assert_func, .{ .name = "__assert_func", .linkage = .weak });

@export(&malloc, .{ .name = "malloc", .linkage = .weak });
@export(&calloc, .{ .name = "calloc", .linkage = .weak });
@export(&free, .{ .name = "free", .linkage = .weak });
@export(&puts, .{ .name = "puts", .linkage = .weak });

@export(&gettimeofday, .{ .name = "gettimeofday", .linkage = .weak });
@export(&sleep, .{ .name = "sleep", .linkage = .weak });
@export(&usleep, .{ .name = "usleep", .linkage = .weak });
@export(&vTaskDelay, .{ .name = "vTaskDelay", .linkage = .weak });
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These can be overwritten by the user. They are provided in case there is no available implementation. But they are required for esp_wifi drivers to work


.data :
{
. = ALIGN(16);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also encountered some alignment caused crashes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I get littering the linker with align directives, but do you actually know for sure that these need align 16, or are you just going this high to be safe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I used 16 because I got a warning from the linker that .data should be aligned to 16 bytes.

@github-actions github-actions bot dismissed their stale review January 16, 2026 08:51

Updating with new lint results

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🔍 Lint Results

Found 3 issues on changed lines in 3 files:

  • examples/espressif/esp/src/tcp_server.zig: 1 issue
  • port/espressif/esp/src/hal/radio/osi.zig: 1 issue
  • port/espressif/esp/src/hal/system.zig: 1 issue

@github-actions github-actions bot dismissed their stale review January 16, 2026 09:29

Updating with new lint results

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🔍 Lint Results

Found 3 issues on changed lines in 3 files:

  • examples/espressif/esp/src/tcp_server.zig: 1 issue
  • port/espressif/esp/src/hal/radio/osi.zig: 1 issue
  • port/espressif/esp/src/hal/system.zig: 1 issue

@tact1m4n3
Copy link
Collaborator Author

I managed to crash the formatter :) The problematic file is esp/cpus/esp_riscv.zig. I also tested the formatter from master and that crashes as well.

@github-actions github-actions bot dismissed their stale review January 16, 2026 09:43

Updating with new lint results

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🔍 Lint Results

Found 1 issue on changed lines in 1 file:

  • port/espressif/esp/src/hal/radio/osi.zig: 1 issue

@tact1m4n3 tact1m4n3 marked this pull request as ready for review January 16, 2026 09:50
@github-actions github-actions bot dismissed their stale review January 17, 2026 09:39

Updating with new lint results

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🔍 Lint Results

Found 1 issue on changed lines in 1 file:

  • port/espressif/esp/src/hal/radio/osi.zig: 1 issue


.data :
{
. = ALIGN(16);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I get littering the linker with align directives, but do you actually know for sure that these need align 16, or are you just going this high to be safe?

const systimer = @import("systimer.zig");

// How it works?
// For simple task to task context switches, only necessary registers are
Copy link
Collaborator

Choose a reason for hiding this comment

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

what are 'necessary'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only the registers that the compiler wants to save. This happens through the clobbers from the inline asm context_switch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I mean to say that you should be more specific in the comment. It's defined by the ABI?

// For simple task to task context switches, only necessary registers are
// saved. But if a higher priority task becomes available during the handling
// of an interrupt, a task switch is forced by saving the entire state of the
// task on the stack. What is interresting is that the two context switches are
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// task on the stack. What is interresting is that the two context switches are
// task on the stack. What is interesting is that the two context switches are

microzig.cpu.interrupt.enable(rtos_options.yield_interrupt);

// unit0 is already enabled as it is used by `hal.time`.
if (rtos_options.systimer_unit != .unit0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it OK to do this? should it be a compile error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the user overrides the systimer_unit to be something other than the unit used by esp.time which is already enabled, we should enable it. Otherwise, enabling the unit is unnecessary.

Comment on lines +286 to +289
while (!timeout.is_reached()) {
yield(.{ .wait = .{
.timeout = timeout,
} });
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am betting zig fmt will complain about this

}
};

pub const TypeErasedQueue = struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this and the normal queue could maybe go into some utility library? Just something about the rtos state would have to be generalized.

If you think it would fit, a TODO is fine by me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well this queue sort of comes with the rtos. The implementation is made specifically for it. Though, it would be nice to allow the user to swap the RTOS for wifi.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah ok, that's fine by me, then

},
};

const SSID = "SSID";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment here and a compile error if it's not set

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add a comment. If we add a compile error, wouldn't CI fail?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah good point.

@tact1m4n3 tact1m4n3 marked this pull request as draft January 19, 2026 20:41
@Grazfather Grazfather mentioned this pull request Jan 19, 2026
// TODO: config
const coex_enabled: bool = false;

pub var gpa: std.mem.Allocator = undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit but GPA implies general purpose allocator. Do they normally call it GPA unless it's actually that (or the debug allocator now)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Afaik, it is a good practice to name allocators gpa or arena to imply what kind of allocator do you need to provide. If it is an arena, you expect it to leak memory.

tim.deadline = .init_relative(get_time_since_boot(), duration);
tim.periodic = if (repeat) duration else null;
} else {
log.warn("timer not found based on ets_timer", .{});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we actually survive these? Should we be panicking if it's game over here rather than failing later on?

if (find(ets_timer)) |tim| {
tim.deadline = .no_deadline;
} else {
log.warn("timer not found based on ets_timer", .{});
Copy link
Collaborator

Choose a reason for hiding this comment

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

For better debugging, would be nice to print which function failed (arm vs done vs disarm)

},
};

const SSID = "SSID";
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah good point.

}
};

pub const TypeErasedQueue = struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah ok, that's fine by me, then

const systimer = @import("systimer.zig");

// How it works?
// For simple task to task context switches, only necessary registers are
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I mean to say that you should be more specific in the comment. It's defined by the ABI?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants