Microzig Generation 2 Build Interface (#23)

* Rework for MicroZig Gen 2 Build
* Drops CI

---------

Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
wch-ch32v003
Felix Queißner 1 year ago committed by GitHub
parent 80e5e69420
commit dbbbb1392f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +0,0 @@
github: MasterQ32

@ -1,19 +0,0 @@
name: Build
on:
push:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
optimize: [Debug, ReleaseSmall, ReleaseFast, ReleaseSafe]
steps:
- uses: actions/checkout@v2
- uses: goto-bus-stop/setup-zig@v2.1.1
with:
version: 0.11.0
- name: Build
run: zig build install "-Doptimize=${{matrix.optimize}}"

3
.gitmodules vendored

@ -1,3 +0,0 @@
[submodule "deps/microzig"]
path = deps/microzig
url = https://github.com/ZigEmbeddedGroup/microzig.git

@ -1,19 +1,65 @@
const std = @import("std");
const microzig = @import("microzig");
pub const chips = @import("src/chips.zig");
fn path(comptime suffix: []const u8) std.Build.LazyPath {
return .{
.cwd_relative = comptime ((std.fs.path.dirname(@src().file) orelse ".") ++ suffix),
};
}
pub fn build(b: *std.build.Builder) void {
const optimize = b.standardOptimizeOption(.{});
inline for (@typeInfo(chips).Struct.decls) |decl| {
const exe = microzig.addEmbeddedExecutable(b, .{
.name = decl.name ++ ".minimal",
.source_file = .{
.path = "test/programs/minimal.zig",
pub const chips = struct {
pub const nrf52840 = .{
.preferred_format = .elf,
.chip = .{
.name = "nrf52840",
.url = "https://www.nordicsemi.com/products/nrf52840",
.cpu = .cortex_m4,
.register_definition = .{
.json = path("/src/chips/nrf52840.json"),
},
.memory_regions = &.{
.{ .offset = 0x00000000, .length = 0x100000, .kind = .flash },
.{ .offset = 0x20000000, .length = 0x40000, .kind = .ram },
// EXTFLASH
.{ .offset = 0x12000000, .length = 0x8000000, .kind = .flash },
// CODE_RAM
.{ .offset = 0x800000, .length = 0x40000, .kind = .ram },
},
},
};
pub const nrf52832 = .{
.preferred_format = .elf,
.chip = .{
.name = "nrf52",
.url = "https://www.nordicsemi.com/products/nrf52832",
.cpu = .cortex_m4,
.register_definition = .{
.json = path("/src/chips/nrf52.json"),
},
.memory_regions = &.{
.{ .offset = 0x00000000, .length = 0x80000, .kind = .flash },
.{ .offset = 0x20000000, .length = 0x10000, .kind = .ram },
},
.backing = .{ .chip = @field(chips, decl.name) },
.optimize = optimize,
});
exe.installArtifact(b);
}
},
};
};
pub const boards = struct {
pub const nordic = struct {
pub const nRF52840_Dongle = .{
.preferred_format = .elf,
.chip = chips.nrf52840.chip,
.board = .{
.name = "nRF52840 Dongle",
.url = "https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dongle",
.source_file = path("/src/boards/nrf52840-dongle.zig"),
},
};
};
};
pub fn build(b: *std.build.Builder) void {
_ = b;
}

@ -1,10 +1,5 @@
.{
.name = "microzig-nordic-nrf5x",
.version = "0.1.0",
.dependencies = .{
.microzig = .{
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
},
},
.dependencies = .{},
}

@ -0,0 +1 @@
// TODO: Implement board support

@ -1,38 +0,0 @@
const std = @import("std");
const micro = @import("microzig");
const Chip = micro.Chip;
const MemoryRegion = micro.MemoryRegion;
fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse unreachable;
}
pub const nrf52840 = Chip{
.name = "nrf52840",
.source = .{ .path = root_dir() ++ "/chips/nrf52840.zig" },
.json_register_schema = .{ .path = root_dir() ++ "/chips.nrf52840.json" },
.cpu = micro.cpus.cortex_m4,
.memory_regions = &.{
MemoryRegion{ .offset = 0x00000000, .length = 0x100000, .kind = .flash },
MemoryRegion{ .offset = 0x20000000, .length = 0x40000, .kind = .ram },
// EXTFLASH
MemoryRegion{ .offset = 0x12000000, .length = 0x8000000, .kind = .flash },
// CODE_RAM
MemoryRegion{ .offset = 0x800000, .length = 0x40000, .kind = .ram },
},
};
pub const nrf52832 = Chip{
.name = "nrf52",
.source = .{ .path = root_dir() ++ "/chips/nrf52.zig" },
.json_register_schema = .{ .path = root_dir() ++ "/chips.nrf52.json" },
.cpu = micro.cpus.cortex_m4,
.memory_regions = &.{
MemoryRegion{ .offset = 0x00000000, .length = 0x80000, .kind = .flash },
MemoryRegion{ .offset = 0x20000000, .length = 0x10000, .kind = .ram },
},
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save