Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Microzig Generation 2 Build Interface (#26)
Browse files Browse the repository at this point in the history
* Drops microzig dependency
* Starts to port to MicroZig Build Gen 2
* Drops CI

---------

Co-authored-by: Felix "xq" Queißner <[email protected]>
  • Loading branch information
ikskuh and Felix "xq" Queißner authored Sep 22, 2023
1 parent 081683a commit 597843c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1,459 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/build.yml

This file was deleted.

102 changes: 77 additions & 25 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,32 +1,84 @@
const std = @import("std");
const microzig = @import("microzig");

pub const boards = @import("src/boards.zig");
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(boards).Struct.decls) |decl| {
const exe = microzig.addEmbeddedExecutable(b, .{
.name = @field(boards, decl.name).name ++ ".minimal",
.source_file = .{
.path = "test/programs/minimal.zig",
const hal = .{
.source_file = path("/src/hals/ATmega328P.zig"),
};

pub const chips = struct {
pub const atmega328p = .{
.preferred_format = .hex,
.chip = .{
.name = "ATmega328P",
.url = "https://www.microchip.com/en-us/product/atmega328p",
.cpu = .avr5,
.register_definition = .{
.json = path("/src/chips/ATmega328P.json"),
},
.backing = .{ .board = @field(boards, decl.name) },
.optimize = optimize,
});
exe.installArtifact(b);
}
.memory_regions = &.{
.{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
.{ .offset = 0x800100, .length = 2048, .kind = .ram },
},
},
.hal = hal,
};
};

inline for (@typeInfo(chips).Struct.decls) |decl| {
const exe = microzig.addEmbeddedExecutable(b, .{
.name = @field(chips, decl.name).name ++ ".minimal",
.source_file = .{
.path = "test/programs/minimal.zig",
pub const boards = struct {
pub const arduino = struct {
pub const nano = .{
.preferred_format = .hex,
.chip = chips.atmega328p.chip,
.hal = hal,
.board = .{
.name = "Arduino Nano",
.url = "https://docs.arduino.cc/hardware/nano",
.source_file = path("/src/boards/arduino_nano.zig"),
},
.backing = .{ .chip = @field(chips, decl.name) },
.optimize = optimize,
});
exe.installArtifact(b);
}
};

pub const uno_rev3 = .{
.preferred_format = .hex,
.chip = chips.atmega328p.chip,
.hal = hal,
.board = .{
.name = "Arduino Uno",
.url = "https://docs.arduino.cc/hardware/uno-rev3",
.source_file = path("/src/boards/arduino_uno.zig"),
},
};
};
};

pub fn build(b: *std.build.Builder) void {
_ = b;
// const optimize = b.standardOptimizeOption(.{});
// inline for (@typeInfo(boards).Struct.decls) |decl| {
// const exe = microzig.addEmbeddedExecutable(b, .{
// .name = @field(boards, decl.name).name ++ ".minimal",
// .source_file = .{
// .path = "test/programs/minimal.zig",
// },
// .backing = .{ .board = @field(boards, decl.name) },
// .optimize = optimize,
// });
// exe.installArtifact(b);
// }

// inline for (@typeInfo(chips).Struct.decls) |decl| {
// const exe = microzig.addEmbeddedExecutable(b, .{
// .name = @field(chips, decl.name).name ++ ".minimal",
// .source_file = .{
// .path = "test/programs/minimal.zig",
// },
// .backing = .{ .chip = @field(chips, decl.name) },
// .optimize = optimize,
// });
// exe.installArtifact(b);
// }
}
7 changes: 1 addition & 6 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
.{
.name = "microzig-espressif-esp",
.version = "0.1.0",
.dependencies = .{
.microzig = .{
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
},
},
.dependencies = .{},
}
12 changes: 0 additions & 12 deletions src/boards.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,3 @@ const chips = @import("chips.zig");
fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse unreachable;
}

pub const arduino_nano = micro.Board{
.name = "Arduino Nano",
.source = .{ .path = root_dir() ++ "/boards/arduino_nano.zig" },
.chip = chips.atmega328p,
};

pub const arduino_uno = micro.Board{
.name = "Arduino Uno",
.source = .{ .path = root_dir() ++ "/boards/arduino_uno.zig" },
.chip = chips.atmega328p,
};
9 changes: 0 additions & 9 deletions src/chips.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,3 @@ const MemoryRegion = micro.MemoryRegion;
fn root_dir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}

pub const atmega328p = Chip.from_standard_paths(root_dir(), .{
.name = "ATmega328P",
.cpu = micro.cpus.avr5,
.memory_regions = &.{
MemoryRegion{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
MemoryRegion{ .offset = 0x800100, .length = 2048, .kind = .ram },
},
});
Loading

0 comments on commit 597843c

Please sign in to comment.