rp2xxx: `pio.assembler.Output.get_define_by_name` does not compile (declared `u32`, breaks with a `Define`)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 88/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- zig
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Đọc port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig ở phần quanh Output.get_define_by_name và kiểu Define của nó. Issue có ví dụ về kiểm thử hồi quy; hãy bổ sung kiểm thử cho việc tra cứu T1 và chạy zig build test trong port/raspberrypi/rp2xxx. Công việc được xem là hoàn tất khi hàm biên dịch được, trả về giá trị define và kiểm thử thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Output.get_define_by_name (port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig:58-66 on
master) is declared to return u32, but its loop does break define;, which is a
Define{ name, value: i64 }. Every call fails inside the package:
assembler.zig:64:23: error: expected type 'u32', found 'hal.pio.assembler.Define'
Nothing in the tree calls it (grep -rn get_define_by_name finds only the
declaration), so CI never compiles it. The function has been in this shape since at
least 185e906e5 (2024-02-25). Users who want a define by name end up indexing
.defines[i] by position, and that silently reads the wrong constant once the
program's .define lines are reordered.
Versions
| tree | toolchain | result |
|---|---|---|
| microzig 0.15.1 release | zig 0.15.2 | compile error (rc=1), assembler.zig:66:23 |
| microzig master f36d59fb7b22 (tag 0.17.17, 2026-10-10) | zig 0.17.0 | compile error (rc=1), assembler.zig:64:23 |
| master + the fix below | zig 0.17.0 | builds (rc=0) |
Repro
A minimal firmware with microzig as a path dependency, built for boards.raspberrypi.pico:
const microzig = @import("microzig");
const hal = microzig.hal;
const out = hal.pio.assemble(
\\.define PUBLIC T1 3
\\.program p
\\ nop
, .{});
comptime {
if (@hasDecl(microzig, "export_startup")) _ = microzig.export_startup();
}
pub fn main() void {
const t1 = comptime out.get_define_by_name("T1");
if (t1 != 3) @compileError("expected T1 == 3");
while (true) {}
}
Expected: builds; T1 == 3.
Actual (master, zig 0.17.0):
deps/microzig/port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig:64:23: error: expected type 'u32', found 'hal.pio.assembler.Define'
break define;
^~~~~~
repro.zig:18:47: note: called at comptime here
const t1 = comptime out.get_define_by_name("T1");
Fix
Return the define's value, typed as Define.value is (i64), so no cast or range
check is needed. The patch also adds a test, so CI compiles the function from now on:
- ) u32 {
+ ) i64 {
return for (output.defines) |define| {
if (std.mem.eql(u8, name, define.name))
- break define;
+ break define.value;
test "get_define_by_name" {
const output = comptime assemble(.RP2040,
\\.define PUBLIC T1 3
\\.program testprog
\\ nop
, .{});
try std.testing.expectEqual(@as(i64, 3), comptime output.get_define_by_name("T1"));
}
zig build test in port/raspberrypi/rp2xxx: master gives 135/135 passed; with the
patch it gives 136/136 passed (rc=0).
(Alternative, if you would rather mirror get_program_by_name: return Define
and have callers write .value. The patch keeps the name's promise of a value.)
I have the patch ready and can open it as a PR if you'd like.
- Ngôn ngữ chính
- Zig
- Star
- 2.3k
- Fork
- 198
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 37
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ZigEmbeddedGroup/microzig
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
ZigEmbeddedGroup/microzig#1085 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ZigEmbeddedGroup/microzig#1061 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ZigEmbeddedGroup/microzig#1059 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
regz: AVR peripherals generated at address 0 when the register-group name matches the module (ATDF)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
ZigEmbeddedGroup/microzig#1072 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AVR (ATmega328P): UART/SPI HAL, drivers.zig, and nRF24L01+ driver (Emakefun RF-Nano V3.0)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
ZigEmbeddedGroup/microzig#1069 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ZigEmbeddedGroup/microzig
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#122261 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
area: core priority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
EPFL-TOP/smart-microscope-control#132 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
FujiNetWIFI/fujinet-config#264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
scope:mqtt-bridge type:feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bvis/aegis-hass#588 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày