rp2xxx: `pio.assembler.Output.get_define_by_name` does not compile (declared `u32`, breaks with a `Define`)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- zig
- 领域
- embedded-iot
调研方向
阅读 port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig 中 Output.get_define_by_name 及其 Define 类型附近的代码。Issue 包含一个回归测试示例;请添加查找 T1 的测试覆盖,并在 port/raspberrypi/rp2xxx 中运行 zig build test。函数能够编译、返回 define 值且测试通过,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Zig
- 星标
- 2.3k
- 派生
- 198
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 37
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ZigEmbeddedGroup/microzig 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 69/100
ZigEmbeddedGroup/microzig#1085 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1061 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
ZigEmbeddedGroup/microzig#1059 · 1 条评论 ·
维护者通常 1 天内回复
-
regz: AVR peripherals generated at address 0 when the register-group name matches the module (ATDF)未关闭
难度 4/5 3-5 天 新手友好度 48/100
ZigEmbeddedGroup/microzig#1072 ·
维护者通常 1 天内回复
-
AVR (ATmega328P): UART/SPI HAL, drivers.zig, and nRF24L01+ driver (Emakefun RF-Nano V3.0)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 35/100
ZigEmbeddedGroup/microzig#1069 · 3 条评论 ·
维护者通常 1 天内回复
查看 ZigEmbeddedGroup/microzig 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
esp-rs/openthread#124 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
ARM-software/CMSIS-DSP#354 ·
-
Legacy switchWarningState decoded with 3 bits per switch since 2.12 (storage uses 2): impossible switch warnings after update可能已有人在做 @GaboITB 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
esp_lvgl_port: lvgl_port_touchpad_read() aborts on a failed touch read (ESP_ERROR_CHECK)可能已有人在做 @udvlp 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100