You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
microzig/build.zig

55 lines
1.5 KiB
Zig

2 years ago
const std = @import("std");
const Builder = std.build.Builder;
const Pkg = std.build.Pkg;
const comptimePrint = std.fmt.comptimePrint;
2 years ago
const chip_path = comptimePrint("{s}/src/rp2040.zig", .{root()});
const board_path = comptimePrint("{s}/src/raspberry_pi_pico.zig", .{root()});
const hal_path = comptimePrint("{s}/src/hal.zig", .{root()});
const linkerscript_path = comptimePrint("{s}/rp2040.ld", .{root()});
pub const BuildOptions = struct {};
2 years ago
pub fn addPiPicoExecutable(
comptime microzig: type,
builder: *Builder,
name: []const u8,
source: []const u8,
_: BuildOptions,
) microzig.EmbeddedExecutable {
2 years ago
const rp2040 = microzig.Chip{
.name = "RP2040",
.path = chip_path,
2 years ago
.cpu = microzig.cpus.cortex_m0plus,
.memory_regions = &.{
.{ .kind = .flash, .offset = 0x10000100, .length = (2048 * 1024) - 256 },
.{ .kind = .flash, .offset = 0x10000000, .length = 256 },
.{ .kind = .ram, .offset = 0x20000000, .length = 256 * 1024 },
},
};
const raspberry_pi_pico = microzig.Board{
.name = "Raspberry Pi Pico",
.path = board_path,
2 years ago
.chip = rp2040,
};
const ret = microzig.addEmbeddedExecutable(
builder,
name,
source,
.{ .board = raspberry_pi_pico },
.{
.hal_package_path = .{ .path = hal_path },
2 years ago
},
);
ret.inner.setLinkerScriptPath(.{ .path = linkerscript_path });
2 years ago
return ret;
}
fn root() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
2 years ago
}