diff --git a/README.md b/README.md index c3bfa27..dda5683 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # microzig-examples + Examples for embedded zig! diff --git a/build.zig b/build.zig index d961288..9ed2c21 100644 --- a/build.zig +++ b/build.zig @@ -1,34 +1,52 @@ const std = @import("std"); const rp2040 = @import("rp2040"); -const microzig_build = @import("microzig"); +const stm32 = @import("stm32"); pub fn build(b: *std.Build) void { - const microzig = microzig_build.init(b, "microzig"); - + const microzig = @import("microzig").init(b, "microzig"); const optimize = b.standardOptimizeOption(.{}); - // `addFirmware` basically works like addExecutable, but takes a - // `microzig.Target` for target instead of a `std.zig.CrossTarget`. - // - // The target will convey all necessary information on the chip, - // cpu and potentially the board as well. - const firmware = microzig.addFirmware(b, .{ - .name = "blinky", - .target = rp2040.boards.raspberry_pi.pico, - .optimize = optimize, - .source_file = .{ .path = "src/blinky.zig" }, - }); + const TargetDesc = struct { + target: @import("microzig").Target, + name: []const u8, + }; + + const available_targets = [_]TargetDesc{ + // RP2040 + .{ .name = "pico", .target = rp2040.boards.raspberry_pi.pico }, + .{ .name = "rp2040-eth", .target = rp2040.boards.waveshare.rp2040_eth }, + .{ .name = "rp2040-plus-4m", .target = rp2040.boards.waveshare.rp2040_plus_4m }, + .{ .name = "rp2040-plus-16m", .target = rp2040.boards.waveshare.rp2040_plus_16m }, + .{ .name = "rp2040-matrix", .target = rp2040.boards.waveshare.rp2040_matrix }, - // Pendant to `getEmittedBin()`: Always returns the path to the output elf file - _ = firmware.getEmittedElf(); + // STM32 + .{ .name = "stm32f103x8", .target = stm32.chips.stm32f103x8 }, + .{ .name = "stm32f303vc", .target = stm32.chips.stm32f303vc }, + .{ .name = "stm32f407vg", .target = stm32.chips.stm32f407vg }, + .{ .name = "stm32f429zit6u", .target = stm32.chips.stm32f429zit6u }, + .{ .name = "stm32f3discovery", .target = stm32.boards.stm32f3discovery }, + .{ .name = "stm32f4discovery", .target = stm32.boards.stm32f4discovery }, + .{ .name = "stm3240geval", .target = stm32.boards.stm3240geval }, + .{ .name = "stm32f429idiscovery", .target = stm32.boards.stm32f429idiscovery }, + }; - // Extension of `getEmittedElf()` that will also convert the file to the given - // binary format. - _ = firmware.getEmittedBin(null); // `null` is preferred format, in this case uf2 + for (available_targets) |dest| { + // `addFirmware` basically works like addExecutable, but takes a + // `microzig.Target` for target instead of a `std.zig.CrossTarget`. + // + // The target will convey all necessary information on the chip, + // cpu and potentially the board as well. + const firmware = microzig.addFirmware(b, .{ + .name = b.fmt("empty-{s}", .{dest.name}), + .target = dest.target, + .optimize = optimize, + .source_file = .{ .path = "src/empty.zig" }, + }); - // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` - // and allows installing the firmware as a typical firmware file. - // - // This will also install into `$prefix/firmware` instead of `$prefix/bin`. - microzig.installFirmware(b, firmware, .{}); + // `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` + // and allows installing the firmware as a typical firmware file. + // + // This will also install into `$prefix/firmware` instead of `$prefix/bin`. + microzig.installFirmware(b, firmware, .{}); + } } diff --git a/build.zig.zon b/build.zig.zon index c1350ee..e44e0ba 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,12 +3,16 @@ .version = "0.1.0", .dependencies = .{ .microzig = .{ - .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/44ab82cac86ab7fbd4e6718021d51a2bb8c4a42c.tar.gz", - .hash = "122039437ab5c8946e3f1f77dec17092f0c6cae9fcd830bce89f03725e75a02d101b", + .url = "https://github.com/ZigEmbeddedGroup/microzig/archive/c6c9ec4516f57638e751141085c9d76120990312.tar.gz", + .hash = "1220af58bdaa721b8189f3a7adfda660517dd354463463388e96d69fe4ceccf80b92", }, .rp2040 = .{ - .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/b9c361be68215d48657ec3684c8a30ebbc74efd5.tar.gz", - .hash = "1220aa6da071763468a358e82af753db23513e12120cf749bdb8bb4f8ea2a8b6da7b", + .url = "https://github.com/ZigEmbeddedGroup/raspberrypi-rp2040/archive/67d36eebb0fbd89633db1a51d6d2bcb049f2066a.tar.gz", + .hash = "122094bf268f45b188f3916f9e5964f4257414afaafba98a455ac47d25389a456832", + }, + .stm32 = .{ + .url = "https://github.com/ZigEmbeddedGroup/stmicro-stm32/archive/cb2893707efa6aa289fa72f02959ad5f2d9db2a1.tar.gz", + .hash = "12208cab5f60ef97cac4165ad694f3ba0c7b28f279538c1539b74f7c152f34fe306d", }, }, } diff --git a/ezpkg.sh b/ezpkg.sh index b1f61da..577c8b4 100755 --- a/ezpkg.sh +++ b/ezpkg.sh @@ -2,4 +2,8 @@ exec ezpkg \ microzig=/home/felix/projects/zeg/microzig \ - rp2040=/home/felix/projects/zeg/device-support-package/rp2040 \ No newline at end of file + microzig.uf2=/home/felix/projects/zeg/uf2 \ + microzig.regz=/home/felix/projects/zeg/regz \ + rp2040=/home/felix/projects/zeg/device-support-package/rp2040 \ + stm32=/home/felix/projects/zeg/device-support-package/stmicro-stm32 + \ No newline at end of file diff --git a/src/empty.zig b/src/empty.zig new file mode 100644 index 0000000..7c6dbbe --- /dev/null +++ b/src/empty.zig @@ -0,0 +1,6 @@ +const std = @import("std"); +const microzig = @import("microzig"); + +pub fn main() void { + // +}