Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- name: Build
run: zig build -Doptimize=ReleaseSmall

- name: Unit Test BSPs
run: zig build run-bsp-tests -Doptimize=ReleaseSmall
- name: Unit Test Ports
run: zig build run-port-tests -Doptimize=ReleaseSmall

- name: Dry run packaging
if: ${{ matrix.os == 'macos-latest' }}
Expand All @@ -45,7 +45,7 @@ jobs:
cd tools/package-test
zig fetch --save=microzig http://localhost:8000/microzig-${MICROZIG_VERSION}.tar.gz
zig build -Doptimize=ReleaseSmall
zig build run-bsp-tests
zig build run-port-tests

# clean up server
jobs -p | xargs kill
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ For MicroZig internals please see the [Design Document](docs/design.md).

* `build/` contains the build components of MicroZig.
* `core/` contains the shared components of MicroZig.
* `bsp/` contains all official board support package.
* `port/` contains all official board support package.
* `examples/` contains examples that can be used with the board support packages.
* `tools/` contains tooling to work *on* MicroZig itself, so deployment, testing, ...
* `design/` contains images and logos
Expand Down
50 changes: 25 additions & 25 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const example_dep_names: []const []const u8 = &.{
"examples/raspberrypi/rp2040",
};

const bsps = .{
.{ "bsp/nordic/nrf5x", @import("bsp/nordic/nrf5x") },
.{ "bsp/nxp/lpc", @import("bsp/nxp/lpc") },
.{ "bsp/microchip/atsam", @import("bsp/microchip/atsam") },
.{ "bsp/microchip/avr", @import("bsp/microchip/avr") },
.{ "bsp/gigadevice/gd32", @import("bsp/gigadevice/gd32") },
.{ "bsp/stmicro/stm32", @import("bsp/stmicro/stm32") },
.{ "bsp/espressif/esp", @import("bsp/espressif/esp") },
.{ "bsp/raspberrypi/rp2040", @import("bsp/raspberrypi/rp2040") },
const ports = .{
.{ "port/nordic/nrf5x", @import("port/nordic/nrf5x") },
.{ "port/nxp/lpc", @import("port/nxp/lpc") },
.{ "port/microchip/atsam", @import("port/microchip/atsam") },
.{ "port/microchip/avr", @import("port/microchip/avr") },
.{ "port/gigadevice/gd32", @import("port/gigadevice/gd32") },
.{ "port/stmicro/stm32", @import("port/stmicro/stm32") },
.{ "port/espressif/esp", @import("port/espressif/esp") },
.{ "port/raspberrypi/rp2040", @import("port/raspberrypi/rp2040") },
};

pub fn build(b: *Build) void {
Expand Down Expand Up @@ -55,11 +55,11 @@ pub fn build(b: *Build) void {
const parts_db_json = b.addInstallFile(parts_db, "parts-db.json");
package_step.dependOn(&parts_db_json.step);

const test_bsps_step = b.step("run-bsp-tests", "Run all platform agnostic tests for BSPs");
inline for (bsps) |bsp| {
const bsp_dep = b.dependency(bsp[0], .{});
if (bsp_dep.builder.top_level_steps.get("test")) |test_step| {
test_bsps_step.dependOn(&test_step.step);
const test_ports_step = b.step("run-port-tests", "Run all platform agnostic tests for Ports");
inline for (ports) |port| {
const port_dep = b.dependency(port[0], .{});
if (port_dep.builder.top_level_steps.get("test")) |test_step| {
test_ports_step.dependOn(&test_step.step);
}
}
}
Expand All @@ -70,7 +70,7 @@ const PartsDb = struct {

const Chip = struct {
identifier: []const u8,
bsp_package: []const u8,
port_package: []const u8,
url: ?[]const u8,
cpu: []const u8,
has_hal: bool,
Expand All @@ -82,7 +82,7 @@ const PartsDb = struct {
};
const Board = struct {
identifier: []const u8,
bsp_package: []const u8,
port_package: []const u8,
chip_idx: u32,
url: ?[]const u8,
output_format: ?[]const u8,
Expand All @@ -94,13 +94,13 @@ fn generate_parts_db(b: *Build) !Build.LazyPath {
var boards = std.ArrayList(PartsDb.Board).init(b.allocator);

@setEvalBranchQuota(20000);
inline for (bsps) |bsp| {
inline for (ports) |port| {
const chips_start_idx = chips.items.len;
inline for (@typeInfo(@field(bsp[1], "chips")).Struct.decls) |decl| {
const target = @field(@field(bsp[1], "chips"), decl.name);
inline for (@typeInfo(@field(port[1], "chips")).Struct.decls) |decl| {
const target = @field(@field(port[1], "chips"), decl.name);
try chips.append(.{
.identifier = decl.name,
.bsp_package = bsp[0],
.port_package = port[0],
.url = target.chip.url,
.cpu = target.chip.cpu.name,
.has_hal = target.hal != null,
Expand All @@ -112,20 +112,20 @@ fn generate_parts_db(b: *Build) !Build.LazyPath {
});
}

inline for (@typeInfo(@field(bsp[1], "boards")).Struct.decls) |decl| {
const target = @field(@field(bsp[1], "boards"), decl.name);
inline for (@typeInfo(@field(port[1], "boards")).Struct.decls) |decl| {
const target = @field(@field(port[1], "boards"), decl.name);
_ = target;
_ = chips_start_idx;

//const chip_idx = inline for (@typeInfo(@field(bsp[1], "chips")).Struct.decls, 0..) |chip_decl, idx| {
// const chip = @field(@field(bsp[1], "chips"), chip_decl.name);
//const chip_idx = inline for (@typeInfo(@field(port[1], "chips")).Struct.decls, 0..) |chip_decl, idx| {
// const chip = @field(@field(port[1], "chips"), chip_decl.name);
// if (std.mem.eql(u8, chip.chip.name, target.chip.name))
// break chips_start_idx + idx;
//} else @compileError("failed to get chip_idx");

try boards.append(.{
.identifier = decl.name,
.bsp_package = bsp[0],
.port_package = port[0],
.chip_idx = 0,
.url = "",
.output_format = null,
Expand Down
16 changes: 8 additions & 8 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
.core = .{ .path = "core" },
.@"tools/regz" = .{ .path = "tools/regz" },
.@"tools/uf2" = .{ .path = "tools/uf2" },
.@"bsp/nordic/nrf5x" = .{ .path = "bsp/nordic/nrf5x" },
.@"bsp/nxp/lpc" = .{ .path = "bsp/nxp/lpc" },
.@"bsp/microchip/atsam" = .{ .path = "bsp/microchip/atsam" },
.@"bsp/microchip/avr" = .{ .path = "bsp/microchip/avr" },
.@"bsp/gigadevice/gd32" = .{ .path = "bsp/gigadevice/gd32" },
.@"bsp/stmicro/stm32" = .{ .path = "bsp/stmicro/stm32" },
.@"bsp/espressif/esp" = .{ .path = "bsp/espressif/esp" },
.@"bsp/raspberrypi/rp2040" = .{ .path = "bsp/raspberrypi/rp2040" },
.@"port/nordic/nrf5x" = .{ .path = "port/nordic/nrf5x" },
.@"port/nxp/lpc" = .{ .path = "port/nxp/lpc" },
.@"port/microchip/atsam" = .{ .path = "port/microchip/atsam" },
.@"port/microchip/avr" = .{ .path = "port/microchip/avr" },
.@"port/gigadevice/gd32" = .{ .path = "port/gigadevice/gd32" },
.@"port/stmicro/stm32" = .{ .path = "port/stmicro/stm32" },
.@"port/espressif/esp" = .{ .path = "port/espressif/esp" },
.@"port/raspberrypi/rp2040" = .{ .path = "port/raspberrypi/rp2040" },

// examples so that we can build them all in one go
.@"examples/nordic/nrf5x" = .{ .path = "examples/nordic/nrf5x" },
Expand Down
2 changes: 1 addition & 1 deletion examples/espressif/esp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Examples for the BSP `espressif-esp`
# Examples for the Port `espressif-esp`

- [Blinky](src/blinky.zig) on [ESP32-C3-32S-Kit](https://www.waveshare.com/wiki/ESP-C3-32S-Kit)
Showcases how to do a simple RGB cycling.
2 changes: 1 addition & 1 deletion examples/espressif/esp/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const esp = @import("microzig/bsp/espressif/esp");
const esp = @import("microzig/port/espressif/esp");

const available_examples = [_]Example{
.{ .target = esp.chips.esp32_c3, .name = "esp32-c3_blinky", .file = "src/blinky.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/espressif/esp/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/espressif/esp" = .{ .path = "../../../bsp/espressif/esp" },
.@"microzig/port/espressif/esp" = .{ .path = "../../../port/espressif/esp" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/gigadevice/gd32/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const gd32 = @import("microzig/bsp/gigadevice/gd32");
const gd32 = @import("microzig/port/gigadevice/gd32");

const available_examples = [_]Example{
.{ .target = gd32.chips.gd32vf103xb, .name = "gd32vf103xb", .file = "src/empty.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/gigadevice/gd32/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/gigadevice/gd32" = .{ .path = "../../../bsp/gigadevice/gd32" },
.@"microzig/port/gigadevice/gd32" = .{ .path = "../../../port/gigadevice/gd32" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/microchip/atsam/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const atsam = @import("microzig/bsp/microchip/atsam");
const atsam = @import("microzig/port/microchip/atsam");

const available_examples = [_]Example{
.{ .target = atsam.chips.atsamd51j19, .name = "atsamd51j19-blinky", .file = "src/blinky.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/microchip/atsam/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/microchip/atsam" = .{ .path = "../../../bsp/microchip/atsam" },
.@"microzig/port/microchip/atsam" = .{ .path = "../../../port/microchip/atsam" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/microchip/avr/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const avr = @import("microzig/bsp/microchip/avr");
const avr = @import("microzig/port/microchip/avr");

const available_examples = [_]Example{
.{ .target = avr.boards.arduino.nano, .name = "arduino-nano_blinky", .file = "src/blinky.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/microchip/avr/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/microchip/avr" = .{ .path = "../../../bsp/microchip/avr" },
.@"microzig/port/microchip/avr" = .{ .path = "../../../port/microchip/avr" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/nordic/nrf5x/build.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const std = @import("std");
const Build = std.Build;
const MicroZig = @import("microzig/build");
const nrf5x = @import("microzig/bsp/nordic/nrf5x");
const nrf5x = @import("microzig/port/nordic/nrf5x");

const available_examples = [_]Example{
.{ .target = nrf5x.boards.nordic_nRF52840_Dongle, .name = "nrf52480-dongle_blinky", .file = "src/blinky.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/nordic/nrf5x/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/nordic/nrf5x" = .{ .path = "../../../bsp/nordic/nrf5x" },
.@"microzig/port/nordic/nrf5x" = .{ .path = "../../../port/nordic/nrf5x" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/nxp/lpc/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Examples for the BSP `nxp-lpc`
# Examples for the Port `nxp-lpc`

- [Blinky](src/blinky.zig) on [nRF52840 Dongle](https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dongle)
TODO: Implement this!
Expand Down
2 changes: 1 addition & 1 deletion examples/nxp/lpc/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const lpc = @import("microzig/bsp/nxp/lpc");
const lpc = @import("microzig/port/nxp/lpc");

const available_examples = [_]ExampleDesc{
.{ .target = lpc.boards.mbed.lpc1768, .name = "mbed-lpc1768_blinky", .file = "src/blinky.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/nxp/lpc/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/nxp/lpc" = .{ .path = "../../../bsp/nxp/lpc" },
.@"microzig/port/nxp/lpc" = .{ .path = "../../../port/nxp/lpc" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2040/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Examples for the BSP `raspberrypi-rp2040`
# Examples for the Port `raspberrypi-rp2040`

## Demos

Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2040/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const rp2040 = @import("microzig/bsp/raspberrypi/rp2040");
const rp2040 = @import("microzig/port/raspberrypi/rp2040");

const available_examples = [_]Example{
// RaspberryPi Boards:
Expand Down
2 changes: 1 addition & 1 deletion examples/raspberrypi/rp2040/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/raspberrypi/rp2040" = .{ .path = "../../../bsp/raspberrypi/rp2040" },
.@"microzig/port/raspberrypi/rp2040" = .{ .path = "../../../port/raspberrypi/rp2040" },
},

.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/stmicro/stm32/build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const MicroZig = @import("microzig/build");
const stm32 = @import("microzig/bsp/stmicro/stm32");
const stm32 = @import("microzig/port/stmicro/stm32");

const available_examples = [_]Example{
.{ .target = stm32.chips.STM32F103C8, .name = "STM32F103C8", .file = "src/blinky.zig" },
Expand Down
2 changes: 1 addition & 1 deletion examples/stmicro/stm32/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
.@"microzig/bsp/stmicro/stm32" = .{ .path = "../../../bsp/stmicro/stm32" },
.@"microzig/port/stmicro/stm32" = .{ .path = "../../../port/stmicro/stm32" },
},

.paths = .{
Expand Down
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,5 @@
.{
.name = "bsp/espressif/esp",
.name = "port/espressif/esp",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
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,5 @@
.{
.name = "bsp/gigadevice/gd32",
.name = "port/gigadevice/gd32",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
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,5 @@
.{
.name = "bsp/microchip/atsam",
.name = "port/microchip/atsam",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
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,5 @@
.{
.name = "bsp/microchip/avr",
.name = "port/microchip/avr",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
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,5 @@
.{
.name = "bsp/nordic/nrf5x",
.name = "port/nordic/nrf5x",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bsp/nxp/lpc/build.zig.zon → port/nxp/lpc/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.{
.name = "bsp/nxp/lpc",
.name = "port/nxp/lpc",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
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,5 @@
.{
.name = "bsp/raspberrypi/rp2040",
.name = "port/raspberrypi/rp2040",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{
Expand Down
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,5 @@
.{
.name = "bsp/stmicro/stm32",
.name = "port/stmicro/stm32",
.version = "0.0.0",
.dependencies = .{
.@"microzig/build" = .{ .path = "../../../build" },
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tools/package-test/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pub fn build(b: *std.Build) void {
});
b.getInstallStep().dependOn(microzig_dep.builder.getInstallStep());

const test_bsps_step = b.step("run-bsp-tests", "Run all platform agnostic tests for BSPs");
test_bsps_step.dependOn(&microzig_dep.builder.top_level_steps.get("run-bsp-tests").?.step);
const test_ports_step = b.step("run-port-tests", "Run all platform agnostic tests for Ports");
test_ports_step.dependOn(&microzig_dep.builder.top_level_steps.get("run-port-tests").?.step);
}
6 changes: 1 addition & 5 deletions tools/parts_db.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ pub fn main() !void {

const output_path = args[1];



var chips = std.ArrayList(MicroZig.Chip).init(allocator);
var boards = std.ArrayList(MicroZig.Board).init(allocator);
inline for (bsps) |bsp| {

}
inline for (port) |port| {}

const json_str = std.json.stringifyAlloc(b.allocator, parts_db, .{}) catch @panic("OOM");

Expand Down