I have made some modifications (nothing conclusive to the point of sending MR).
However, I could not solve the last error involving the linker (ld) not recognizing memcpy.
diff --git a/build.zig b/build.zig
index 09ec19d..f492a75 100644
--- a/build.zig
+++ b/build.zig
@@ -29,11 +29,11 @@ pub fn build(b: *Builder) !void {
try tmp.appendSlice("-Uflash:w:");
try tmp.appendSlice(bin_path);
try tmp.appendSlice(":e");
- break :blk tmp.toOwnedSlice();
+ break :blk tmp.toOwnedSlice() catch unreachable;
};
const upload = b.step("upload", "Upload the code to an Arduino device using avrdude");
- const avrdude = b.addSystemCommand(&.{
+ const avrdude = b.addSystemCommand(&[_][]const u8{
"avrdude",
"-carduino",
"-patmega328p",
@@ -46,7 +46,7 @@ pub fn build(b: *Builder) !void {
avrdude.step.dependOn(&exe.install_step.?.step);
const objdump = b.step("objdump", "Show dissassembly of the code using avr-objdump");
- const avr_objdump = b.addSystemCommand(&.{
+ const avr_objdump = b.addSystemCommand(&[_][]const u8{
"avr-objdump",
"-dh",
bin_path,
@@ -55,7 +55,7 @@ pub fn build(b: *Builder) !void {
avr_objdump.step.dependOn(&exe.install_step.?.step);
const monitor = b.step("monitor", "Opens a monitor to the serial output");
- const screen = b.addSystemCommand(&.{
+ const screen = b.addSystemCommand(&[_][]const u8{
"screen",
tty,
"115200",
diff --git a/src/atmega328p.zig b/src/atmega328p.zig
index 06d4880..35b21bb 100644
--- a/src/atmega328p.zig
+++ b/src/atmega328p.zig
@@ -1313,8 +1313,8 @@ pub fn mmioInt(addr: usize, comptime size: usize, comptime T: type) *volatile Mm
}
const InterruptVector = extern union {
- C: fn () callconv(.C) void,
- Naked: fn () callconv(.Naked) void,
+ C: *const fn () callconv(.C) void,
+ Naked: *const fn () callconv(.Naked) void,
// Interrupt is not supported on arm
};
diff --git a/src/start.zig b/src/start.zig
index 596febc..e60f677 100644
--- a/src/start.zig
+++ b/src/start.zig
@@ -4,8 +4,12 @@ const uart = @import("uart.zig");
const std = @import("std");
const builtin = std.builtin;
-export const vector_table linksection(".vectors") = blk: {
- std.debug.assert(std.mem.eql(u8, "RESET", std.meta.fields(atmega328p.VectorTable)[0].name));
+comptime {
+ @export(vector_table, .{ .name = "vector_table", .linkage = .Strong });
+}
+
+const vector_table linksection(".vectors") = blk: {
+ // std.debug.assert(std.mem.eql(u8, "RESET", std.meta.fields(atmega328p.VectorTable)[0].name));
var asm_str: []const u8 = "jmp _start\n";
const has_interrupts = @hasDecl(main, "interrupts");
@@ -57,7 +61,13 @@ export const vector_table linksection(".vectors") = blk: {
asm_str = asm_str ++ new_insn ++ "\n";
}
- break :blk asm (asm_str);
+ const T = struct {
+ fn _start() callconv(.Naked) void {
+ asm volatile (asm_str);
+ }
+ };
+
+ break :blk T._start;
};
export fn _unhandled_vector() void {
@@ -122,7 +132,7 @@ fn clear_bss() void {
// Probably a good idea to add clobbers here, but compiler doesn't seem to care
}
-pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
+pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace, _: ?usize) noreturn {
// Currently assumes that the uart is initialized in main().
uart.write("PANIC: ");
uart.write(msg);