Skip to content

Commit

Permalink
Update microzig to work on zig master
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnite committed Mar 1, 2024
1 parent a4e8e49 commit 185e906
Show file tree
Hide file tree
Showing 288 changed files with 1,373 additions and 2,608 deletions.
76 changes: 13 additions & 63 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
name: Continuous Integration

env:
# Specify the current Zig version MicroZig uses:
ZIG_VERSION: 0.11.0
DEPLOYMENT_URL: "https://download.microzig.tech"
name: Build

on:
push:
Expand All @@ -12,68 +7,23 @@ on:
branches: [main]

jobs:
generate-packages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true # required for "git describe"
fetch-depth: 0

- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}

- name: Install PIP packages
run: |
pip install -r tools/requirements.txt
- name: Generate and validate packages
run: |
./tools/bundle.py
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: microzig-deploy/

validate-packages:
runs-on: ubuntu-latest
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [
ubuntu-latest,
windows-latest,
macos-latest,
]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true # required for "git describe"
fetch-depth: 0

- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}

- name: Install PIP packages
run: |
pip install -r tools/requirements.txt
- name: Generate packages
run: |
./tools/bundle.py --debug
- name: Spawn local web server
uses: Eun/http-server-action@v1
with:
directory: "${{ github.workspace }}/microzig-deploy"
port: 8080
content-types: |
{
"gz": "application/gzip",
"json": "application/json"
}
version: master

- name: Validate examples
run: |
mkdir -p "${{ github.workspace }}/microzig-test"
./tools/validate-all-examples.sh --build-root "${{ github.workspace }}/microzig-test"
- name: Build
run: zig build -Doptimize=ReleaseSmall
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ microzig-deploy/
.direnv/
__pycache__/
.venv
boxzer-out
File renamed without changes.
4 changes: 0 additions & 4 deletions board-support/espressif-esp/microzig-package.json

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/gigadevice-gd32/microzig-package.json

This file was deleted.

41 changes: 0 additions & 41 deletions board-support/microchip-atsam/build.zig

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/microchip-atsam/microzig-package.json

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/microchip-avr/microzig-package.json

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/nordic-nrf5x/microzig-package.json

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/nxp-lpc/microzig-package.json

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/raspberrypi-rp2040/microzig-package.json

This file was deleted.

4 changes: 0 additions & 4 deletions board-support/stmicro-stm32/microzig-package.json

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const MicroZig = @import("microzig-build");
const MicroZig = @import("microzig/build");

pub const microzig_board_support = MicroZig.registerBoardSupport(@This());

Expand Down Expand Up @@ -35,7 +35,7 @@ pub const chips = struct {
.name = "ESP32-C3",
.url = "https://www.espressif.com/en/products/socs/esp32-c3",

.cpu = .{ .custom = &esp_riscv },
.cpu = esp_riscv,

.register_definition = .{
.svd = path("/src/chips/ESP32-C3.svd"),
Expand Down
11 changes: 11 additions & 0 deletions bsp/espressif/esp/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.{
.name = "microzig/bsp/espressif/esp",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
},
.paths = .{
"build.zig",
"build.zig.zon",
},
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ pub const startup_logic = struct {
_rv32_trap,
};
};

pub fn export_startup_logic() void {
// no op as it's already being exported
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig-build");
const Build = std.Build;
const MicroZig = @import("microzig/build");

pub const microzig_board_support = MicroZig.registerBoardSupport(@This());

Expand All @@ -18,7 +19,7 @@ pub const chips = struct {
.preferred_format = .elf,
.chip = .{
.name = "GD32VF103",
.cpu = .riscv32_imac,
.cpu = MicroZig.cpus.riscv32_imac,
.memory_regions = &.{
.{ .offset = 0x08000000, .length = 128 * 1024, .kind = .flash },
.{ .offset = 0x20000000, .length = 32 * 1024, .kind = .ram },
Expand All @@ -34,7 +35,7 @@ pub const chips = struct {
.preferred_format = .elf,
.chip = .{
.name = "GD32VF103",
.cpu = .riscv32_imac,
.cpu = MicroZig.cpus.riscv32_imac,
.memory_regions = &.{
.{ .offset = 0x08000000, .length = 64 * 1024, .kind = .flash },
.{ .offset = 0x20000000, .length = 20 * 1024, .kind = .ram },
Expand Down Expand Up @@ -62,7 +63,7 @@ pub const boards = struct {
};
};

pub fn build(b: *std.build.Builder) void {
pub fn build(b: *Build) void {
_ = b;
// const optimize = b.standardOptimizeOption(.{});
// inline for (@typeInfo(boards).Struct.decls) |decl| {
Expand Down
11 changes: 11 additions & 0 deletions bsp/gigadevice/gd32/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.{
.name = "microzig/bsp/gigadevice/gd32",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
},
.paths = .{
"build.zig",
"build.zig.zon",
},
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions bsp/microchip/atsam/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const std = @import("std");
const MicroZig = @import("microzig/build");

pub const microzig_board_support = MicroZig.registerBoardSupport(@This());

pub fn build(b: *std.Build) void {
_ = b;
// Dummy func to make package manager happy
}

fn root() []const u8 {
return comptime (std.fs.path.dirname(@src().file) orelse ".");
}

const build_root = root();

pub const chips = struct {
pub const atsamd51j19 = MicroZig.Target{
.preferred_format = .elf,
.chip = .{
.name = "ATSAMD51J19A",
.url = "https://www.microchip.com/en-us/product/ATSAMD51J19A",
.cpu = MicroZig.cpus.cortex_m4,
.register_definition = .{
.atdf = .{ .path = build_root ++ "/src/chips/ATSAMD51J19A.atdf" },
},
.memory_regions = &.{
.{ .kind = .flash, .offset = 0x00004000, .length = 512 * 1024 }, // Embedded Flash
.{ .kind = .ram, .offset = 0x20000000, .length = 192 * 1024 }, // Embedded SRAM
.{ .kind = .ram, .offset = 0x47000000, .length = 8 * 1024 }, // Backup SRAM
.{ .kind = .flash, .offset = 0x00804000, .length = 512 }, // NVM User Row
},
},
};
};

pub const boards = struct {
// empty right now
};
11 changes: 11 additions & 0 deletions bsp/microchip/atsam/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.{
.name = "microzig/bsp/microchip/atsam",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
},
.paths = .{
"build.zig",
"build.zig.zon",
},
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const std = @import("std");
const MicroZig = @import("microzig-build");
const Build = std.Build;
const MicroZig = @import("microzig/build");

pub const microzig_board_support = MicroZig.registerBoardSupport(@This());

fn path(comptime suffix: []const u8) std.Build.LazyPath {
fn path(comptime suffix: []const u8) Build.LazyPath {
return .{
.cwd_relative = comptime ((std.fs.path.dirname(@src().file) orelse ".") ++ suffix),
};
Expand All @@ -19,7 +20,7 @@ pub const chips = struct {
.chip = .{
.name = "ATmega328P",
.url = "https://www.microchip.com/en-us/product/atmega328p",
.cpu = .avr5,
.cpu = MicroZig.cpus.avr5,
.register_definition = .{
.json = path("/src/chips/ATmega328P.json"),
},
Expand Down Expand Up @@ -58,7 +59,7 @@ pub const boards = struct {
};
};

pub fn build(b: *std.build.Builder) void {
pub fn build(b: *Build) void {
_ = b;
// const optimize = b.standardOptimizeOption(.{});
// inline for (@typeInfo(boards).Struct.decls) |decl| {
Expand Down
11 changes: 11 additions & 0 deletions bsp/microchip/avr/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.{
.name = "microzig/bsp/microchip/avr",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
},
.paths = .{
"build.zig",
"build.zig.zon",
},
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig-build");
const Build = std.Build;
const MicroZig = @import("microzig/build");

pub const microzig_board_support = MicroZig.registerBoardSupport(@This());

Expand All @@ -15,7 +16,7 @@ pub const chips = struct {
.chip = .{
.name = "nrf52840",
.url = "https://www.nordicsemi.com/products/nrf52840",
.cpu = .cortex_m4,
.cpu = MicroZig.cpus.cortex_m4,
.register_definition = .{
.json = path("/src/chips/nrf52840.json"),
},
Expand All @@ -37,7 +38,7 @@ pub const chips = struct {
.chip = .{
.name = "nrf52",
.url = "https://www.nordicsemi.com/products/nrf52832",
.cpu = .cortex_m4,
.cpu = MicroZig.cpus.cortex_m4,
.register_definition = .{
.json = path("/src/chips/nrf52.json"),
},
Expand All @@ -63,6 +64,6 @@ pub const boards = struct {
};
};

pub fn build(b: *std.build.Builder) void {
pub fn build(b: *Build) void {
_ = b;
}
Loading

0 comments on commit 185e906

Please sign in to comment.