rp2xxx: `pio.assembler.Output.get_define_by_name` does not compile (declared `u32`, breaks with a `Define`)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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を実行してください。関数がコンパイルされ、定義の値を返し、テストが成功すれば完了です。
索引モデルが 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時間
- マージ済み PR(30日)
- 37
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
ZigEmbeddedGroup/microzig#1069 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
ZigEmbeddedGroup/microzig の issue をすべて見る
似ている issue
-
stlink_probe._get_board_id() raises TypeError, not KeyError, when mbed.htm exists but has no TargetID対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
problem
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Koenkk/zigbee2mqtt#33373 ·
メンテナーはふだん 1 日以内に返信
-
priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
zephyrproject-rtos/zephyr#122050 ·
メンテナーはふだん 3 日以内に返信
-
1 type: problem 2 scope: firmware 3 good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
SpaceTeam/STS1_COBC_SW#511 ·
-
documentation good first issue
難易度 2/5 半日 初心者へのやさしさ 60/100
imaaiagent/fumi#1 ·