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

Commit 597843c

Browse files
ikskuhFelix "xq" Queißner
andauthored
Microzig Generation 2 Build Interface (#26)
* Drops microzig dependency * Starts to port to MicroZig Build Gen 2 * Drops CI --------- Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
1 parent 081683a commit 597843c

File tree

6 files changed

+78
-1459
lines changed

6 files changed

+78
-1459
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

build.zig

Lines changed: 77 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,84 @@
11
const std = @import("std");
2-
const microzig = @import("microzig");
32

4-
pub const boards = @import("src/boards.zig");
5-
pub const chips = @import("src/chips.zig");
3+
fn path(comptime suffix: []const u8) std.Build.LazyPath {
4+
return .{
5+
.cwd_relative = comptime ((std.fs.path.dirname(@src().file) orelse ".") ++ suffix),
6+
};
7+
}
68

7-
pub fn build(b: *std.build.Builder) void {
8-
const optimize = b.standardOptimizeOption(.{});
9-
inline for (@typeInfo(boards).Struct.decls) |decl| {
10-
const exe = microzig.addEmbeddedExecutable(b, .{
11-
.name = @field(boards, decl.name).name ++ ".minimal",
12-
.source_file = .{
13-
.path = "test/programs/minimal.zig",
9+
const hal = .{
10+
.source_file = path("/src/hals/ATmega328P.zig"),
11+
};
12+
13+
pub const chips = struct {
14+
pub const atmega328p = .{
15+
.preferred_format = .hex,
16+
.chip = .{
17+
.name = "ATmega328P",
18+
.url = "https://www.microchip.com/en-us/product/atmega328p",
19+
.cpu = .avr5,
20+
.register_definition = .{
21+
.json = path("/src/chips/ATmega328P.json"),
1422
},
15-
.backing = .{ .board = @field(boards, decl.name) },
16-
.optimize = optimize,
17-
});
18-
exe.installArtifact(b);
19-
}
23+
.memory_regions = &.{
24+
.{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
25+
.{ .offset = 0x800100, .length = 2048, .kind = .ram },
26+
},
27+
},
28+
.hal = hal,
29+
};
30+
};
2031

21-
inline for (@typeInfo(chips).Struct.decls) |decl| {
22-
const exe = microzig.addEmbeddedExecutable(b, .{
23-
.name = @field(chips, decl.name).name ++ ".minimal",
24-
.source_file = .{
25-
.path = "test/programs/minimal.zig",
32+
pub const boards = struct {
33+
pub const arduino = struct {
34+
pub const nano = .{
35+
.preferred_format = .hex,
36+
.chip = chips.atmega328p.chip,
37+
.hal = hal,
38+
.board = .{
39+
.name = "Arduino Nano",
40+
.url = "https://docs.arduino.cc/hardware/nano",
41+
.source_file = path("/src/boards/arduino_nano.zig"),
2642
},
27-
.backing = .{ .chip = @field(chips, decl.name) },
28-
.optimize = optimize,
29-
});
30-
exe.installArtifact(b);
31-
}
43+
};
44+
45+
pub const uno_rev3 = .{
46+
.preferred_format = .hex,
47+
.chip = chips.atmega328p.chip,
48+
.hal = hal,
49+
.board = .{
50+
.name = "Arduino Uno",
51+
.url = "https://docs.arduino.cc/hardware/uno-rev3",
52+
.source_file = path("/src/boards/arduino_uno.zig"),
53+
},
54+
};
55+
};
56+
};
57+
58+
pub fn build(b: *std.build.Builder) void {
59+
_ = b;
60+
// const optimize = b.standardOptimizeOption(.{});
61+
// inline for (@typeInfo(boards).Struct.decls) |decl| {
62+
// const exe = microzig.addEmbeddedExecutable(b, .{
63+
// .name = @field(boards, decl.name).name ++ ".minimal",
64+
// .source_file = .{
65+
// .path = "test/programs/minimal.zig",
66+
// },
67+
// .backing = .{ .board = @field(boards, decl.name) },
68+
// .optimize = optimize,
69+
// });
70+
// exe.installArtifact(b);
71+
// }
72+
73+
// inline for (@typeInfo(chips).Struct.decls) |decl| {
74+
// const exe = microzig.addEmbeddedExecutable(b, .{
75+
// .name = @field(chips, decl.name).name ++ ".minimal",
76+
// .source_file = .{
77+
// .path = "test/programs/minimal.zig",
78+
// },
79+
// .backing = .{ .chip = @field(chips, decl.name) },
80+
// .optimize = optimize,
81+
// });
82+
// exe.installArtifact(b);
83+
// }
3284
}

build.zig.zon

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
.{
22
.name = "microzig-espressif-esp",
33
.version = "0.1.0",
4-
.dependencies = .{
5-
.microzig = .{
6-
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/0b3be0a4cc7e6d45714cb09961efc771e364723c.tar.gz",
7-
.hash = "1220ada6d01db7b3d0aa8642df89b1af9ee71b681438249e9a7efb2275fc4cf32152",
8-
},
9-
},
4+
.dependencies = .{},
105
}

src/boards.zig

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,3 @@ const chips = @import("chips.zig");
55
fn root_dir() []const u8 {
66
return std.fs.path.dirname(@src().file) orelse unreachable;
77
}
8-
9-
pub const arduino_nano = micro.Board{
10-
.name = "Arduino Nano",
11-
.source = .{ .path = root_dir() ++ "/boards/arduino_nano.zig" },
12-
.chip = chips.atmega328p,
13-
};
14-
15-
pub const arduino_uno = micro.Board{
16-
.name = "Arduino Uno",
17-
.source = .{ .path = root_dir() ++ "/boards/arduino_uno.zig" },
18-
.chip = chips.atmega328p,
19-
};

src/chips.zig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,3 @@ const MemoryRegion = micro.MemoryRegion;
66
fn root_dir() []const u8 {
77
return std.fs.path.dirname(@src().file) orelse ".";
88
}
9-
10-
pub const atmega328p = Chip.from_standard_paths(root_dir(), .{
11-
.name = "ATmega328P",
12-
.cpu = micro.cpus.avr5,
13-
.memory_regions = &.{
14-
MemoryRegion{ .offset = 0x000000, .length = 32 * 1024, .kind = .flash },
15-
MemoryRegion{ .offset = 0x800100, .length = 2048, .kind = .ram },
16-
},
17-
});

0 commit comments

Comments
 (0)