Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

rp2xxx: `pio.assembler.Output.get_define_by_name` does not compile (declared `u32`, breaks with a `Define`)

Open Beginner friendly
#1,086 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
zig
Domain
embedded-iot

Research direction

Read port/raspberrypi/rp2xxx/src/hal/pio/assembler.zig around Output.get_define_by_name and its Define type. The issue includes a regression test example; add coverage for looking up T1 and run zig build test in port/raspberrypi/rp2xxx. Done means the function compiles, returns the define value, and the test passes.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Zig
Stars
2.3k
Forks
198
Avg merge
1d 8h
Merged PRs (30d)
37

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ZigEmbeddedGroup/microzig

All issues in ZigEmbeddedGroup/microzig

Similar issues

More Embedded & IoT issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.