Skip to content

Commit 20fd289

Browse files
committed
Get esp examples building
1 parent f6cdb2b commit 20fd289

File tree

14 files changed

+1216
-300
lines changed

14 files changed

+1216
-300
lines changed

core/src/failing.zig

Lines changed: 931 additions & 0 deletions
Large diffs are not rendered by default.

core/src/microzig.zig

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,15 @@ pub const panic = std.debug.FullPanic(struct {
4242
pub fn panic_fn(message: []const u8, first_trace_address: ?usize) noreturn {
4343
std.log.err("panic: {s}", .{message});
4444

45-
var frame_index: usize = 0;
46-
if (@errorReturnTrace()) |trace| frame_index = utilities.dump_stack_trace(trace);
45+
var error_trace_count: usize = 0;
46+
if (@errorReturnTrace()) |trace| error_trace_count = utilities.dump_stack_trace(trace, 0);
4747

4848
var addr_buf: [20]usize = undefined;
4949
var stacktrace = std.debug.captureCurrentStackTrace(.{
5050
.first_address = first_trace_address orelse @returnAddress(),
51+
.allow_unsafe_unwind = true,
5152
}, &addr_buf);
52-
53-
_ = utilities.dump_stack_trace(&stacktrace);
54-
//var iter = std.debug.StackIterator.init(first_trace_address orelse @returnAddress(), null);
55-
//while (iter.next()) |address| : (frame_index += 1) {
56-
// std.log.err("{d: >3}: 0x{X:0>8}", .{ frame_index, address });
57-
//}
53+
_ = utilities.dump_stack_trace(&stacktrace, error_trace_count);
5854

5955
// Attach a breakpoint. this might trigger another panic internally, so
6056
// only do that if requested.

core/src/start.zig

Lines changed: 2 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const std = @import("std");
22
const builtin = @import("builtin");
33
const microzig = @import("microzig");
44
const app = @import("app");
5+
const failing = @import("failing.zig");
56

67
// Use microzig panic handler if not defined by an application
78
pub const panic = if (!@hasDecl(app, "panic")) microzig.panic else app.panic;
@@ -16,7 +17,7 @@ pub const std_options: std.Options = .{
1617
.logFn = microzig.options.logFn,
1718
};
1819

19-
pub const std_options_debug_io: std.Io = nop();
20+
pub const std_options_debug_io: std.Io = failing.io;
2021

2122
// Startup logic:
2223
comptime {
@@ -95,142 +96,3 @@ export fn microzig_main() noreturn {
9596
// Main returned, just hang around here a bit.
9697
microzig.hang();
9798
}
98-
99-
fn nop() std.Io {
100-
return .{
101-
.userdata = null,
102-
.vtable = &.{
103-
.async = async,
104-
.concurrent = concurrent,
105-
.await = await,
106-
.cancel = cancel,
107-
.select = select,
108-
109-
.groupAsync = groupAsync,
110-
.groupConcurrent = groupConcurrent,
111-
.groupAwait = groupAwait,
112-
.groupCancel = groupCancel,
113-
114-
.recancel = recancel,
115-
.swapCancelProtection = swapCancelProtection,
116-
.checkCancel = checkCancel,
117-
118-
.futexWait = futexWait,
119-
.futexWaitUncancelable = futexWaitUncancelable,
120-
.futexWake = futexWake,
121-
122-
.dirCreateDir = dirCreateDir,
123-
.dirCreateDirPath = dirCreateDirPath,
124-
.dirCreateDirPathOpen = dirCreateDirPathOpen,
125-
.dirStat = dirStat,
126-
.dirStatFile = dirStatFile,
127-
.dirAccess = dirAccess,
128-
.dirCreateFile = dirCreateFile,
129-
.dirCreateFileAtomic = dirCreateFileAtomic,
130-
.dirOpenFile = dirOpenFile,
131-
.dirOpenDir = dirOpenDir,
132-
.dirClose = dirClose,
133-
.dirRead = dirRead,
134-
.dirRealPath = dirRealPath,
135-
.dirRealPathFile = dirRealPathFile,
136-
.dirDeleteFile = dirDeleteFile,
137-
.dirDeleteDir = dirDeleteDir,
138-
.dirRename = dirRename,
139-
.dirRenamePreserve = dirRenamePreserve,
140-
.dirSymLink = dirSymLink,
141-
.dirReadLink = dirReadLink,
142-
.dirSetOwner = dirSetOwner,
143-
.dirSetFileOwner = dirSetFileOwner,
144-
.dirSetPermissions = dirSetPermissions,
145-
.dirSetFilePermissions = dirSetFilePermissions,
146-
.dirSetTimestamps = dirSetTimestamps,
147-
.dirHardLink = dirHardLink,
148-
149-
.fileStat = fileStat,
150-
.fileLength = fileLength,
151-
.fileClose = fileClose,
152-
.fileWriteStreaming = fileWriteStreaming,
153-
.fileWritePositional = fileWritePositional,
154-
.fileWriteFileStreaming = fileWriteFileStreaming,
155-
.fileWriteFilePositional = fileWriteFilePositional,
156-
.fileReadStreaming = fileReadStreaming,
157-
.fileReadPositional = fileReadPositional,
158-
.fileSeekBy = fileSeekBy,
159-
.fileSeekTo = fileSeekTo,
160-
.fileSync = fileSync,
161-
.fileIsTty = fileIsTty,
162-
.fileEnableAnsiEscapeCodes = fileEnableAnsiEscapeCodes,
163-
.fileSupportsAnsiEscapeCodes = fileSupportsAnsiEscapeCodes,
164-
.fileSetLength = fileSetLength,
165-
.fileSetOwner = fileSetOwner,
166-
.fileSetPermissions = fileSetPermissions,
167-
.fileSetTimestamps = fileSetTimestamps,
168-
.fileLock = fileLock,
169-
.fileTryLock = fileTryLock,
170-
.fileUnlock = fileUnlock,
171-
.fileDowngradeLock = fileDowngradeLock,
172-
.fileRealPath = fileRealPath,
173-
.fileHardLink = fileHardLink,
174-
175-
.processExecutableOpen = processExecutableOpen,
176-
.processExecutablePath = processExecutablePath,
177-
.lockStderr = lockStderr,
178-
.tryLockStderr = tryLockStderr,
179-
.unlockStderr = unlockStderr,
180-
.processSetCurrentDir = processSetCurrentDir,
181-
.processReplace = processReplace,
182-
.processReplacePath = processReplacePath,
183-
.processSpawn = processSpawn,
184-
.processSpawnPath = processSpawnPath,
185-
.childWait = childWait,
186-
.childKill = childKill,
187-
188-
.progressParentFile = progressParentFile,
189-
190-
.now = now,
191-
.sleep = sleep,
192-
193-
.random = random,
194-
.randomSecure = randomSecure,
195-
196-
.netListenIp = netListenIpUnavailable,
197-
.netListenUnix = netListenUnixUnavailable,
198-
.netAccept = netAcceptUnavailable,
199-
.netBindIp = netBindIpUnavailable,
200-
.netConnectIp = netConnectIpUnavailable,
201-
.netConnectUnix = netConnectUnixUnavailable,
202-
.netClose = netCloseUnavailable,
203-
.netShutdown = netShutdownUnavailable,
204-
.netRead = netReadUnavailable,
205-
.netWrite = netWriteUnavailable,
206-
.netWriteFile = netWriteFileUnavailable,
207-
.netSend = netSendUnavailable,
208-
.netReceive = netReceiveUnavailable,
209-
.netInterfaceNameResolve = netInterfaceNameResolveUnavailable,
210-
.netInterfaceName = netInterfaceNameUnavailable,
211-
.netLookup = netLookupUnavailable,
212-
},
213-
};
214-
}
215-
216-
fn async(
217-
_: ?*anyopaque,
218-
_: []u8,
219-
_: std.Alignment,
220-
_: []const u8,
221-
_: std.Alignment,
222-
_: *const fn (context: *const anyopaque, result: *anyopaque) void,
223-
) ?*std.Io.AnyFuture {
224-
return null;
225-
}
226-
227-
fn concurrent(
228-
_: ?*anyopaque,
229-
_: usize,
230-
_: std.mem.Alignment,
231-
_: []const u8,
232-
_: std.mem.Alignment,
233-
_: *const fn (context: *const anyopaque, result: *anyopaque) void,
234-
) std.Io.ConcurrentError!*std.Io.AnyFuture {
235-
return error.ConcurrencyUnavailable;
236-
}

core/src/utilities.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ pub fn SliceVector(comptime Slice: type) type {
6161
@compileError("Slice must have a slice type!");
6262

6363
const item_ptr_attrs: std.builtin.Type.Pointer.Attributes = .{
64-
.alignment = @min(type_info.pointer.alignment, @alignOf(type_info.pointer.child)),
65-
.address_space = type_info.pointer.address_space,
66-
.is_const = type_info.pointer.is_const,
67-
.is_volatile = type_info.pointer.is_volatile,
68-
.is_allowzero = type_info.pointer.is_allowzero,
64+
.@"align" = @min(type_info.pointer.alignment, @alignOf(type_info.pointer.child)),
65+
.@"addrspace" = type_info.pointer.address_space,
66+
.@"const" = type_info.pointer.is_const,
67+
.@"volatile" = type_info.pointer.is_volatile,
68+
.@"allowzero" = type_info.pointer.is_allowzero,
6969
};
7070

7171
return struct {
@@ -479,7 +479,7 @@ test "SliceVector.Iterator.next_chunk" {
479479
}
480480
}
481481

482-
pub fn dump_stack_trace(trace: *std.builtin.StackTrace) usize {
482+
pub fn dump_stack_trace(trace: *std.builtin.StackTrace, start_index: usize) usize {
483483
const frame_count = @min(trace.index, trace.instruction_addresses.len);
484484

485485
var frame_index: usize = 0;
@@ -489,7 +489,7 @@ pub fn dump_stack_trace(trace: *std.builtin.StackTrace) usize {
489489
frame_index = (frame_index + 1) % trace.instruction_addresses.len;
490490
}) {
491491
const address = trace.instruction_addresses[frame_index];
492-
std.log.err("{d: >3}: 0x{X:0>8}", .{ frame_index, address });
492+
std.log.err("{d: >3}: 0x{X:0>8}", .{ start_index + frame_index, address });
493493
}
494494

495495
return frame_count;

examples/espressif/esp/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn build(b: *std.Build) void {
1414

1515
const targets = [_]TargetDescription{
1616
.{ .prefix = "esp32_c3", .target = mb.ports.esp.chips.esp32_c3 },
17-
.{ .prefix = "esp32_c3_direct_boot", .target = mb.ports.esp.chips.esp32_c3_direct_boot },
17+
// .{ .prefix = "esp32_c3_direct_boot", .target = mb.ports.esp.chips.esp32_c3_direct_boot },
1818
.{ .prefix = "esp32_c3_flashless", .target = mb.ports.esp.chips.esp32_c3_flashless },
1919
};
2020

port/espressif/esp/ld/esp32_c3/direct_boot_sections.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ SECTIONS
4949

5050
microzig_data_load_start = ORIGIN(DROM) + _irom_size + _drom_size;
5151
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
52+
53+
/DISCARD/ :
54+
{
55+
*(.eh_frame_hdr)
56+
*(.eh_frame)
57+
}
5258
}

port/espressif/esp/ld/esp32_c3/flashless_sections.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ SECTIONS
3030
} > DRAM
3131

3232
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
33+
34+
/DISCARD/ :
35+
{
36+
*(.eh_frame_hdr)
37+
*(.eh_frame)
38+
}
3339
}

port/espressif/esp/ld/esp32_c3/image_boot_sections.ld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,10 @@ SECTIONS
7474
} > DRAM
7575

7676
PROVIDE(__global_pointer$ = microzig_data_start + 0x800);
77+
78+
/DISCARD/ :
79+
{
80+
*(.eh_frame_hdr)
81+
*(.eh_frame)
82+
}
7783
}

port/espressif/esp/src/hal/efuse.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub fn read_mac() [6]u8 {
1111
return mac;
1212
}
1313

14-
pub fn read(comptime what: Item) @Type(.{ .int = .{ .bits = what.bit_length, .signedness = .unsigned } }) {
15-
const OutputType = @Type(.{ .int = .{ .bits = what.bit_length, .signedness = .unsigned } });
14+
pub fn read(comptime what: Item) @Int(.unsigned, what.bit_length) {
15+
const OutputType = @Int(.unsigned, what.bit_length);
1616

1717
const block_byte_offsets = [_]u8{ 0x2C, 0x44, 0x5C };
1818
if (what.block >= block_byte_offsets.len) @compileError("invalid block");

0 commit comments

Comments
 (0)