Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to zig master, move uf2 and regz to monorepo #178

Merged
merged 0 commits into from
Apr 26, 2024
Merged

Conversation

mattnite
Copy link
Contributor

No description provided.

@mattnite mattnite marked this pull request as draft February 26, 2024 01:40
@tobiaskohlbau tobiaskohlbau mentioned this pull request Feb 26, 2024
3 tasks
@ikskuh
Copy link
Contributor

ikskuh commented Feb 28, 2024

Before merging, we have to branch into a zig-0.11.0 branch which i will backport as long as feasible

@ikskuh
Copy link
Contributor

ikskuh commented Feb 28, 2024

Also can we incorporate the microzig-package.json into build.zig.zon for the packages? Afaik Zig will ignore additional fields, so we can encode the data at a single point

@mattnite
Copy link
Contributor Author

@MasterQ32 need some advice on how we want to deal with a breakage:

/Users/mattnite/zig/0.12.0-dev.3076+6e078883e/files/lib/std/std.zig:206:34: error: ambiguous reference
pub const options: Options = if (@hasDecl(root, "std_options")) root.std_options else .{};
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
core/src/start.zig:19:5: note: declared here
pub const std_options = if (@hasDecl(app, "std_options"))
~~~~^~~~~
examples/raspberrypi/rp2040/src/usb_hid.zig:150:5: note: declared here
pub const std_options = struct {
~~~~^~~~~
referenced by:
    scope_levels: /Users/mattnite/zig/0.12.0-dev.3076+6e078883e/files/lib/std/log.zig:115:25
    logEnabled: /Users/mattnite/zig/0.12.0-dev.3076+6e078883e/files/lib/std/log.zig:130:17
    log__anon_6179: /Users/mattnite/zig/0.12.0-dev.3076+6e078883e/files/lib/std/log.zig:123:19
    info__anon_3903: /Users/mattnite/zig/0.12.0-dev.3076+6e078883e/files/lib/std/log.zig:194:16
    task: core/src/core/usb.zig:95:40
    main: examples/raspberrypi/rp2040/src/usb_hid.zig:177:23
    microzig_main: core/src/start.zig:82:18

It looks like root simultaneously refers to the declarations of all modules in a compilation. We had a really slick system before where we'd override defaults that made sense for software made with MicroZig, but still allowed users to override as they pleased. All I can think of now is to set std_options in start.zig, and then we'll have to forward options from microzig_options to std_options.

@ikskuh
Copy link
Contributor

ikskuh commented Feb 29, 2024

It looks like root simultaneously refers to the declarations of all modules in a compilation. We had a really slick system before where we'd override defaults that made sense for software made with MicroZig, but still allowed users to override as they pleased.

I guess @andrewrk should take a look at this here. Sounds like a bug in Zig, but might also be by design.

All I can think of now is to set std_options in start.zig, and then we'll have to forward options from microzig_options to std_options.

But i'd be fine with this.

Copy link
Contributor

@ikskuh ikskuh left a comment

Choose a reason for hiding this comment

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

Really quick review, didn't go through the big changes. Example usage on RP2040 looks fine so far, and this is the most important part of the whole project anyways

Comment on lines 16 to 25
.paths = .{
"README.md",
"build.zig",
"build.zig.zon",
"LICENSE",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This is missing the src/generate_linkerscript.zig file, README.md does not exist, LICENCE is missing.

I guess we should perform a final cleanup in the end, and also only package files present in .paths to the website?


const available_examples = [_]Example{
// RaspberryPi Boards:
.{ .target = rp2040.boards.raspberrypi.pico, .name = "pico_adc", .file = "src/adc.zig" },
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with that change back to what we had before, but i'd add a generic function to add findTarget back somehow.
We don't have to expose it as the primary interface, but it makes things easier if we want to pass the target device from the outside

@mattnite mattnite marked this pull request as ready for review March 1, 2024 06:15
@mattnite
Copy link
Contributor Author

mattnite commented Mar 1, 2024

Re: std_options changing to a struct instance: Actually I like this change, it was pretty easy to do the same for interrupts and it improves discoverability as zls completions help let the user know what interrupts they can define.

In addition, turning of building of examples for AVR for now. I see the following issue:

// error: the following command failed with 1 compilation errors:
//Users/mattnite/zig/0.12.0-dev.3097+5c0766b6c/files/zig build-exe -freference-trace=256 -OReleaseSmall -target avr-freestanding-eabi -mcpu avr5 --dep app --dep microzig -Mroot=/Users/mattnite/code/microzig/core/src/start.zig --dep microzig -Mapp=/Users/mattnite/code/microzig/examples/microchip/avr/src/blinky.zig --dep config --dep chip --dep cpu --dep hal --dep board -Mmicrozig=/Users/mattnite/code/microzig/core/src/microzig.zig -Mconfig=/Users/mattnite/code/microzig/zig-cache/c/303c67fccae4ec4bb03ec2180082b67b/options.zig --dep microzig -Mchip=/Users/mattnite/code/microzig/zig-cache/o/2c86b0de714a8b4409eb761d16297c00/chip.zig --dep microzig -Mcpu=/Users/mattnite/code/microzig/core/src/cpus/avr5.zig --dep microzig -Mhal=/Users/mattnite/code/microzig/bsp/microchip/avr/src/hals/ATmega328P.zig --dep microzig -Mboard=/Users/mattnite/code/microzig/bsp/microchip/avr/src/boards/arduino_uno.zig --cache-dir /Users/mattnite/code/microzig/zig-cache --global-cache-dir /Users/mattnite/.cache/zig --name arduino-nano_blinky -static -fcompiler-rt --script /Users/mattnite/code/microzig/zig-cache/o/2c186d936508aa71bea517796451c3f9/linker.ld --listen=-
//install
//mq install
//   mq install generated to arduino-nano_blinky.hex
//      mq objcopy generated
//         mq zig build-exe arduino-nano_blinky ReleaseSmall avr-freestanding-eabi 1 errors
///Users/mattnite/zig/0.12.0-dev.3097+5c0766b6c/files/lib/std/debug.zig:403:14: error: reached unreachable code
//    if (!ok) unreachable; // assertion failure
//             ^~~~~~~~~~~
///Users/mattnite/zig/0.12.0-dev.3097+5c0766b6c/files/lib/std/os/wasi.zig:12:11: note: called from here
//    assert(@alignOf(i16) == 2);
//    ~~~~~~^~~~~~~~~~~~~~~~~~~~

@ikskuh
Copy link
Contributor

ikskuh commented Mar 1, 2024

In addition, turning of building of examples for AVR for now.

Yeah that might be reasonable. I think we should focus on the refactor, then start fixing the AVR stuff

I see the following issue …

That looks like someone assumed overaligned types :D Afaik, AVR allows everything to be align(1)

Re: std_options changing to a struct instance: Actually I like this change, it was pretty easy to do the same for interrupts and it improves discoverability as zls completions help let the user know what interrupts they can define.

Hell, yeah!

@xdBronch
Copy link

in case this hasnt been said anywhere the alignment assertion problem is ziglang/zig#19665
the std_options change accidentally made some wasi checks run too eagerly

@mattnite mattnite merged commit 12ff1b7 into main Apr 26, 2024
3 checks passed
@mattnite mattnite deleted the zig-master branch April 26, 2024 04:11
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.

3 participants