Adds examples for espressif/esp, gigadevice/gd32

wch-ch32v003
Felix "xq" Queißner 8 months ago
parent 2ef68047de
commit 7dd20383fb

2
.gitignore vendored

@ -5,4 +5,4 @@ microzig-deploy/
.gdbinit .gdbinit
.lldbinit .lldbinit
.direnv/ .direnv/
__pycache__/ __pycache__/

@ -1,45 +1,45 @@
const std = @import("std"); const std = @import("std");
const esp = @import("esp"); const MicroZig = @import("microzig-build");
const available_targets = [_]TargetDesc{ const available_examples = [_]Example{
.{ .name = "esp32-c3", .target = esp.chips.esp32_c3 }, .{ .target = "chip:esp32_c3", .name = "esp32-c3_blinky", .file = "src/blinky.zig" },
};
const available_examples = [_][]const u8{
"src/blinky.zig",
}; };
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const microzig = @import("microzig").init(b, "microzig"); const microzig = MicroZig.createBuildEnvironment(b, .{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
for (available_targets) |target| { const show_targets_step = b.step("show-targets", "Shows all available MicroZig targets");
for (available_examples) |example| { show_targets_step.dependOn(microzig.getShowTargetsStep());
// `addFirmware` basically works like addExecutable, but takes a
// `microzig.Target` for target instead of a `std.zig.CrossTarget`. for (available_examples) |example| {
// const target = microzig.findTarget(example.target).?;
// The target will convey all necessary information on the chip,
// cpu and potentially the board as well. // `addFirmware` basically works like addExecutable, but takes a
const firmware = microzig.addFirmware(b, .{ // `microzig.Target` for target instead of a `std.zig.CrossTarget`.
.name = b.fmt("{s}-{s}", .{ std.fs.path.stem(example), target.name }), //
.target = target.target, // The target will convey all necessary information on the chip,
.optimize = optimize, // cpu and potentially the board as well.
.source_file = .{ .path = example }, const firmware = microzig.addFirmware(b, .{
}); .name = example.name,
.target = target,
// `installFirmware()` is the MicroZig pendant to `Build.installArtifact()` .optimize = optimize,
// and allows installing the firmware as a typical firmware file. .source_file = .{ .path = example.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.
// For debugging, we also always install the firmware as an ELF file //
microzig.installFirmware(b, firmware, .{ .format = .elf }); // This will also install into `$prefix/firmware` instead of `$prefix/bin`.
} microzig.installFirmware(b, firmware, .{});
// For debugging, we also always install the firmware as an ELF file
microzig.installFirmware(b, firmware, .{ .format = .elf });
} }
} }
const TargetDesc = struct { const Example = struct {
target: @import("microzig").Target, target: []const u8,
name: []const u8, name: []const u8,
file: []const u8,
}; };

@ -1,18 +0,0 @@
.{
.name = "microzig-nxp-lpc-examples",
.version = "0.1.0",
.dependencies = .{
.microzig = .{
.url = "https://public.devspace.random-projects.net/packages/microzig-build.tar.gz",
.hash = "1220db1de385b765aa45a04719c199d7ab8306fcca6ac1a12b487ed589a69d05a665",
},
.@"microzig-core" = .{
.url = "https://public.devspace.random-projects.net/packages/microzig-core.tar.gz",
.hash = "1220f72de650278d4184dd4a43992189246b520a5c137b54fca05d7a44df8b828267",
},
.@"microzig-bsp-rp2040" = .{
.url = "https://public.devspace.random-projects.net/packages/board-support/raspberrypi/rp2040.tar.gz",
.hash = "1220b170e56d2bd85b96bd8b7f40f2890cf9926da2fcb86967e466a3c87486f31c43",
},
},
}

@ -0,0 +1,7 @@
{
"package_name": "espressif/esp",
"package_type": "example",
"inner_dependencies": [
"espressif/esp"
]
}

@ -1,17 +1,22 @@
const std = @import("std"); const std = @import("std");
const gd32 = @import("gd32"); const MicroZig = @import("microzig-build");
const available_examples = [_]Example{ const available_examples = [_]Example{
// .{ .name = "gd32vf103xb", .target = gd32.chips.gd32vf103xb, .file = "src/blinky.zig" }, .{ .target = "chip:gd32vf103xb", .name = "gd32vf103xb", .file = "src/empty.zig" },
// .{ .name = "gd32vf103x8", .target = gd32.chips.gd32vf103x8, .file = "src/blinky.zig" }, .{ .target = "chip:gd32vf103x8", .name = "gd32vf103x8", .file = "src/empty.zig" },
// .{ .name = "sipeed-longan_nano", .target = gd32.boards.sipeed.longan_nano, .file = "src/blinky.zig" }, .{ .target = "board:sipeed/longan_nano", .name = "sipeed-longan_nano", .file = "src/empty.zig" },
}; };
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const microzig = @import("microzig").init(b, "microzig"); const microzig = MicroZig.createBuildEnvironment(b, .{});
const optimize = .ReleaseSmall; // The others are not really an option on AVR const optimize = b.standardOptimizeOption(.{});
const show_targets_step = b.step("show-targets", "Shows all available MicroZig targets");
show_targets_step.dependOn(microzig.getShowTargetsStep());
for (available_examples) |example| { for (available_examples) |example| {
const target = microzig.findTarget(example.target).?;
// `addFirmware` basically works like addExecutable, but takes a // `addFirmware` basically works like addExecutable, but takes a
// `microzig.Target` for target instead of a `std.zig.CrossTarget`. // `microzig.Target` for target instead of a `std.zig.CrossTarget`.
// //
@ -19,7 +24,7 @@ pub fn build(b: *std.Build) void {
// cpu and potentially the board as well. // cpu and potentially the board as well.
const firmware = microzig.addFirmware(b, .{ const firmware = microzig.addFirmware(b, .{
.name = example.name, .name = example.name,
.target = example.target, .target = target,
.optimize = optimize, .optimize = optimize,
.source_file = .{ .path = example.file }, .source_file = .{ .path = example.file },
}); });
@ -36,7 +41,7 @@ pub fn build(b: *std.Build) void {
} }
const Example = struct { const Example = struct {
target: @import("microzig").Target, target: []const u8,
name: []const u8, name: []const u8,
file: []const u8, file: []const u8,
}; };

@ -1,14 +0,0 @@
.{
.name = "microzig-gigadevice-gd32-examples",
.version = "0.1.0",
.dependencies = .{
.microzig = .{
.url = "https://github.com/ZigEmbeddedGroup/microzig/archive/c6c9ec4516f57638e751141085c9d76120990312.tar.gz",
.hash = "1220af58bdaa721b8189f3a7adfda660517dd354463463388e96d69fe4ceccf80b92",
},
.gd32 = .{
.url = "https://github.com/ZigEmbeddedGroup/gigadevice-gd32/archive/9324753cc3b8e7afe83fcda085bcfe76681a3be3.tar.gz",
.hash = "122043ff4dcbc342f25dbb936b0d9eaa701ac3509e2cbe6764be37b90d31c7a385d0",
},
},
}

@ -0,0 +1,7 @@
{
"package_name": "gigadevice/gd32",
"package_type": "example",
"inner_dependencies": [
"gigadevice/gd32"
]
}

@ -0,0 +1,6 @@
const std = @import("std");
const microzig = @import("microzig");
pub fn main() void {
//
}
Loading…
Cancel
Save