It starts at the vector table which specifies the initial stack and the reset entry point. main.zig/[1]Section 2.3.4 Vector table, p37)
export var vector_table linksection(".vector_table") = packed struct {
initial_sp: u32 = model.stack_bottom,
reset: EntryPoint = reset,
The reset function prepares memory (copies initial data from flash to ram and sets other data to 0.) It then prepares the uart and timer and displays the up-time every second. main.zig
fn reset() callconv(.C) noreturn {
@import("generated/generated_linker_files/generated_prepare_memory.zig").prepareMemory();
Uart.prepare();
Timers[0].prepare();
Terminal.clearScreen();
Terminal.move(1, 1);
log("https://github.com/markfirmware/zig-vector-table is running on a microbit!", .{});
var t = TimeKeeper.ofMilliseconds(1000);
var i: u32 = 0;
while (true) {
Uart.update();
if (t.isFinishedThenReset()) {
i += 1;
Terminal.move(2, 1);
log("up and running for {} seconds!", .{i});
The system is comprised of 256KB of flash and 16KB of ram memories: system_model.zig/[2]Memory Organization, p21
[1] Cortex-M0 Devices Generic User Guide